I am developing a web application and get this error but can't make sense of it (I've looked at similar questions but the answers there don't seem to apply to my problem)
Can anyone make sense of this?
Please help me.
[WARN] Exception while dispatching incoming RPC call
java.lang.ClassCastException: java.lang.NoClassDefFoundError cannot be cast to java.lang.Exception
at net.sf.gilead.gwt.PersistentRemoteService.processCall(PersistentRemoteService.java:177)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:373)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1494)
at org.realityforge.gwt.cache_filter.GWTGzipFilter.doFilter(GWTGzipFilter.java:57)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1482)
at ... (more eclipse.jetty...)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:748)
[ERROR] 500 - POST /webproj/login (127.0.0.1) 57 bytes
Request headers
Host: (...)
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: text/x-gwt-rpc; charset=utf-8
(leaving some stuff out)
Connection: keep-alive
Response headers
Content-Type: text/plain
Related
I am trying to implement CORS where the client and server are in the same URL using CORS Filter.
Below is the code I have implemented
CORS Filter
package com.core.web.spring.cors;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class CORSFilter implements Filter{
#Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res;
HttpServletRequest request = (HttpServletRequest) req;
((HttpServletResponse) res).addHeader("Access-Control-Allow-Origin", "http://192.168.0.103:1111");
((HttpServletResponse) res).addHeader("Access-Control-Allow-Methods",
"GET, POST");
((HttpServletResponse) res).addHeader("Access-Control-Max-Age", "3600");
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
response.setStatus(HttpServletResponse.SC_OK);
} else {
chain.doFilter(req, res);
}
}
}
web.xml
<filter>
<filter-name>cors</filter-name>
<filter-class>com.core.web.spring.cors.CORSFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>cors</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
I have set the Access-Control-Allow-Origin as http://192.168.0.103:1111. I am changing the origin to http://192.168.0.108:1111 from the postman tool. But instead of blocking the request, it is executing it. I am getting a successful response.
Below is the request header and response header
Request Header
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Connection: keep-alive
Content-Length: 1296
Content-Type: text/html; charset=UTF-8`enter code here`
Host: 192.168.0.103:1111
Origin: http://192.168.0.108:1111
Referer: http://192.168.0.103:1111/SampleTest/index.html
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36
X-Requested-With: XMLHttpRequest
Response Header
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST
Access-Control-Allow-Origin: http://192.168.0.103:1111
Access-Control-Max-Age: 3600
Connection: keep-alive
Content-Length: 1210
Date: Sat, 03 Jul 2021 06:11:55 GMT
Server: WildFly/11
Strict-Transport-Security: max-age=7776000; includeSubdomains
X-Content-Type-Options: nosniff
X-FRAME-OPTIONS: SAMEORIGIN
X-Powered-By: Undertow/1
Can anyone help me with this?
Postman doesn't care about SOP (Same-Origin Policy), it's a dev tool, not a browser.
CORS (Cross-Origin Resource Sharing) and SOP (Same-Origin Policy) are server-side configurations that clients decide to enforce or not.
Related to clients
Most Browsers do enforce it to prevent issues related to CSRF attacks.
Most Development tools don't care about it. Postman being dev tool will not give much importance to CORS header, you will need something else to test.
There are chrome extensions that can help you test CORS on your browser.
I am getting jackson deserialisation error when I upgraded spring cloud netflix from 1.3.0.M1 -> 1.3.0.RELEASE.
The Post request that I hit is
Received [POST /wms-mdm/catalog HTTP/1.1
Host: localhost:8093
Content-Type: application/json
Origin: http://localhost:8093
Accept-Encoding: gzip, deflate
Connection: keep-alive
Accept: */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Safari/602.1.50
Referer: http://localhost:8093/wms-mdm/swagger-ui.html
Content-Length: 99
Accept-Language: en-us
With Data
{
"clientCatalogId": "7",
"shortDescription": "Dummy Catalog",
"longDescription": "Dummy Catalog"
}]
The error I am getting is:
com.fasterxml.jackson.databind.JsonMappingException: Could not find creator property with name 'id' (in class com.gor.platform.mdm.core.pojo.Catalog)
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:270) ~[jackson-databind-2.8.7.jar:2.8.7]
at com.fasterxml.jackson.databind.DeserializationContext.reportMappingException(DeserializationContext.java:1234) ~[jackson-databind-2.8.7.jar:2.8.7]
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.addBeanProps(BeanDeserializerFactory.java:551) ~[jackson-databind-2.8.7.jar:2.8.7]
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:226) ~[jackson-databind-2.8.7.jar:2.8.7]
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:141) ~[jackson-databind-2.8.7.jar:2.8.7]
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:403) ~[jackson-databind-2.8.7.jar:2.8.7]
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:349) ~[jackson-databind-2.8.7.jar:2.8.7]
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264) ~[jackson-databind-2.8.7.jar:2.8.7]
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244) ~[jackson-databind-2.8.7.jar:2.8.7]
at com.fasterxml.jackson.databind.deser.DeserializerCache.hasValueDeserializerFor(DeserializerCache.java:191) ~[jackson-databind-2.8.7.jar:2.8.7]
at com.fasterxml.jackson.databind.DeserializationContext.hasValueDeserializerFor(DeserializationContext.java:421) ~[jackson-databind-2.8.7.jar:2.8.7]
at com.fasterxml.jackson.databind.ObjectMapper.canDeserialize(ObjectMapper.java:2713) ~[jackson-databind-2.8.7.jar:2.8.7]
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:162) ~[spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:195) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:150) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:128) [spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121) [spring-web-4.3.7.RELEASE.jar:4.3.7.RELEASE]
When I downgrade netflix cloud to old version things works fine. Anyone can help?
Adding explicit dependency for jackson-databind 2.8.8 solved the issue. Looks like some problem with 2.8.7
Recently I got a requirement from one of our customer. They provided a WSDL to call their service. They are doing IP whitelisting for authentication. I gave my server public IP and it got whitelisted. First, I tested that service through SOAP UI tool and it got worked without any issues. Then I integrated through JAVA code and it got failed. I am getting an exception like
Unable to sendViaPost to url[https://apps.greystar.com/gsWebService/gsExtract.asmx]
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
at org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.handleResponse(HTTPSenderImpl.java:343) ~[axis2-transport-http-1.7.1.jar:1.7.1]
at org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.sendViaPost(HTTPSenderImpl.java:213) ~[axis2-transport-http-1.7.1.jar:1.7.1]
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:121) [axis2-transport-http-1.7.1.jar:1.7.1]
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:403) [axis2-transport-http-1.7.1.jar:1.7.1]
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:234) [axis2-transport-http-1.7.1.jar:1.7.1]
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:431) [axis2-kernel-1.7.1.jar:1.7.1]
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:399) [axis2-kernel-1.7.1.jar:1.7.1]
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225) [axis2-kernel-1.7.1.jar:1.7.1]
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:150) [axis2-kernel-1.7.1.jar:1.7.1]
at com.reputation.r4e.integrator.greystar.ExtractDataStub.greystarExtract(ExtractDataStub.java:300) [classes/:na]
at com.reputation.r4e.integrator.recordreader.GreystarLocationImportRecordReader.getGreystarExtractResponse(GreystarLocationImportRecordReader.java:198) [classes/:na]
at com.reputation.r4e.integrator.recordreader.GreystarLocationImportRecordReader.process(GreystarLocationImportRecordReader.java:97) [classes/:na]
at com.reputation.r4e.integrator.impl.DefaultPipeline.flow(DefaultPipeline.java:33) [classes/:na]
at com.reputation.r4e.integrator.impl.DefaultPipeline.process(DefaultPipeline.java:52) [classes/:na]
at com.reputation.r4e.integrator.importer.NullImporter.process(NullImporter.java:38) [classes/:na]
at com.reputation.r4e.integrator.impl.DefaultPipeline.flow(DefaultPipeline.java:33) [classes/:na]
at com.reputation.r4e.integrator.impl.DefaultPipeline.process(DefaultPipeline.java:52) [classes/:na]
at com.reputation.r4e.integrator.IntegrationRunner$IntegrationRunnable.run(IntegrationRunner.java:87) [classes/:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
It's saying 401 unauthorised error. How it got worked through SOAP UI and why its not working through a JAVA client.?
I monitor http traffic through TCPMon and except headers all are same. So I added the headers which got from the SOAP UI tool to my JAVA Client but still no luck. I am getting the same 401 unauthorised error.
Here are the soap request of both SOAP UI and through JAVA Client.
SOAP UI Request:
POST https://apps.greystar.com/gsWebService/gsExtract.asmx HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/soap+xml;charset=UTF-8;action="https://apps.greystar.com/greystarExtract"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Content-Length: 692
Host: apps.greystar.com
Connection: Keep-Alive
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:apps="https://apps.greystar.com/">
<soap:Header/>
<soap:Body>
<apps:greystarExtract>
<apps:axmlVendorCode>VENDOR_CODE</apps:axmlVendorCode>
<apps:axmlToken>PASSWORD</apps:axmlToken>
<apps:axmlExtractType>PROPERTY_LIST</apps:axmlExtractType>
<apps:axmlFormat>XML</apps:axmlFormat>
<apps:axmlParameters></apps:axmlParameters>
</apps:greystarExtract>
</soap:Body>
</soap:Envelope>
JAVA CLIENT Request:
POST /gsWebService/gsExtract.asmx HTTP/1.1
Content-Type: application/soap+xml; charset=UTF-8; action="https://apps.greystar.com/greystarExtract
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36[\r][\n]
Connection: Keep-Alive
Host: apps.greystar.com
Transfer-Encoding: chunked
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header />
<soapenv:Body>
<ns1:greystarExtract xmlns:ns1="https://apps.greystar.com/">
<ns1:axmlVendorCode>VENDOR_CODE</ns1:axmlVendorCode>
<ns1:axmlToken>PASSWORD</ns1:axmlToken>
<ns1:axmlExtractType>PROPERTY_LIST</ns1:axmlExtractType>
<ns1:axmlFormat>JSON</ns1:axmlFormat>
<ns1:axmlParameters></ns1:axmlParameters>
</ns1:greystarExtract>
</soapenv:Body>
</soapenv:Envelope>
Note: I added JAVA Client headers by looking at the SOAP UI headers. The actual JAVA client headers are below
POST /gsWebService/gsExtract.asmx HTTP/1.1
Content-Type: application/soap+xml; charset=UTF-8;
action="https://apps.greystar.com/greystarExtract
User-Agent: Axis2
Host: apps.greystar.com
Transfer-Encoding: chunked
What could be the reason for failing this through JAVA client.? Can any one please answer my question because I stuck over here.
Thanks in advance,
Amar.T
I tried other third party libraries and its working as expected. I tried CXF and SOAP UI JAVA API and its working as expected. I don't know why its not working with APACHE AXIS2.
If anyone finds the answer why its not working with AXIS2 please post the answer.
Thanks & Regards,
Amar.T
I use jetty-maven-plugin to run my web application:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.12.v20130726</version>
<configuration>
<webApp>
<contextPath>/test</contextPath>
</webApp>
</configuration>
</plugin>
Next, I use nginx to proxify requests:
server {
server_name q.ru;
listen 80;
location / {
proxy_http_version 1.1;
proxy_pass http://127.0.0.1:8080/test;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Now, I open my browser, and send request to http://q.ru (localhost in my /etc/hosts).
I get infinite redirection.
Here is HTTP dialog dump- request from nginx to jetty, and jetty response:
GET /test HTTP/1.1
Host: 127.0.0.1:8080
Connection: close
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
HTTP/1.1 302 Found
Location: http://127.0.0.1:8080/test/
Connection: close
Server: Jetty(8.1.12.v20130726)
Host and path are exactly specified in request. So why does jetty send 302 redirect ?
I'm pretty sure this stackoverflow question might help you, I've been searching for similar thing.
Hope that helps.
Cheers
I'm trying to use Hibernate with GWT (using Gilead) but I got the following error
[WARN] /hibernate/greet
java.lang.NoClassDefFoundError: Could not initialize class net.jaffa.hibernate.server.NewHibernateUtil
at net.jaffa.hibernate.server.GreetingServiceImpl.<init>(GreetingServiceImpl.java:26)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:463)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
[ERROR] 500 - POST /hibernate/greet (127.0.0.1) 3632 bytes
Request headers
Host: 127.0.0.1:8888
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://127.0.0.1:8888/hibernate/hosted.html?hibernate
X-GWT-Permutation: HostedMode
X-GWT-Module-Base: http://127.0.0.1:8888/hibernate/
Content-Type: text/x-gwt-rpc; charset=utf-8
Content-Length: 175
Pragma: no-cache
Cache-Control: no-cache
Response headers
Content-Type: text/html; charset=iso-8859-1
Content-Length: 3632
This is still a new project, just I'm trying to do proof of concept.
Thanks
Feras
java.lang.NoClassDefFoundError: Could not initialize class n.j.h.s.NewHibernateUtil
This error means that the class is found but its initialization failed. Possible causes include
some dependencies are unsatisfied ~or~
an exception is thrown when executing a static initialization block in the class.
In the particular case of a typical HibernateUtil class, I'd bet on the second option. Extract the code of the static initialization block and run it / debug it in a regular main, outside the container (and maybe try to improve the error reporting in case of problem).
java.lang.NoClassDefFoundError means the runtime could not locate the class in its classpath.
It seems you are missing a jar which contains the class net.jaffa.hibernate.server.NewHibernateUtil .