Hi list,
I've started investigating Jersey but I've got stuck right in the beginning.
I've put together a very simple project at
https://github.com/pires/simple-jersey-rest-app with instructions on how to
build and test on Glassfish. I'm using 3.1.1 with Jersey 1.12 bundle
(downloaded and replaced the old jersey-gf-*, jettison and jackson JARs).
I've tried multiple combinations of web.xml, sun-web.xml and code but
perhaps the problem isn't in the configuration or even code as I can see
that the project is correctly deployed and the "AdminService" is found on
initial scanning. Here follows the Glassfish output:
[#|2012-05-22T11:09:25.440+0100|INFO|glassfish3.1.1|org.glassfish.admingui|_ThreadID=17;_ThreadName=Thread-2;|uploadFileName=jersey_rest-0.1.war|#]
[#|2012-05-22T11:09:26.756+0100|INFO|glassfish3.1.1|com.sun.jersey.api.core.PackagesResourceConfig|_ThreadID=20;_ThreadName=Thread-2;|Scanning
for root resource and provider classes in the packages:
rest|#]
[#|2012-05-22T11:09:26.760+0100|INFO|glassfish3.1.1|com.sun.jersey.api.core.ScanningResourceConfig|_ThreadID=20;_ThreadName=Thread-2;|Root
resource classes found:
class rest.AdminService|#]
[#|2012-05-22T11:09:26.760+0100|INFO|glassfish3.1.1|com.sun.jersey.api.core.ScanningResourceConfig|_ThreadID=20;_ThreadName=Thread-2;|No
provider classes found.|#]
[#|2012-05-22T11:09:26.772+0100|INFO|glassfish3.1.1|com.sun.jersey.server.impl.application.WebApplicationImpl|_ThreadID=20;_ThreadName=Thread-2;|Initiating
Jersey application, version 'Jersey: 1.12 02/15/2012 04:51 PM'|#]
Now, when I point my browser to the defined path of the REST service I'm
trying to use, it returns 500 with the following exception in Glassfish
logs:
StandardWrapperValve[Jersey REST Service]: PWC1406: Servlet.service() for
servlet Jersey REST Service threw exception
java.lang.NullPointerException
at
com.sun.jersey.moxy.MoxyMessageBodyWorker.typeIsKnown(MoxyMessageBodyWorker.java:110)
at
com.sun.jersey.moxy.MoxyMessageBodyWorker.isWriteable(MoxyMessageBodyWorker.java:106)
at
com.sun.jersey.core.spi.factory.MessageBodyFactory._getMessageBodyWriter(MessageBodyFactory.java:395)
at
com.sun.jersey.core.spi.factory.MessageBodyFactory._getMessageBodyWriter(MessageBodyFactory.java:382)
at
com.sun.jersey.core.spi.factory.MessageBodyFactory.getMessageBodyWriter(MessageBodyFactory.java:363)
at
com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:266)
at
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1451)
at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1363)
at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1353)
at
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:414)
at
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
at
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
I've checked a Jersey bug, but I'm not sure it's the same problem since the
issue in my test is not related to @Consumes. The bug can be found at
http://java.net/jira/browse/JERSEY-1118.
Any help is highly appreciated. Thank you all,
--
Paulo Pires