users@jersey.java.net

[Jersey] Re: NPE on MoxyMessageBodyWorker.typeIsKnown()

From: Paulo Pires <pjpires_at_gmail.com>
Date: Tue, 22 May 2012 14:33:00 +0100

OK, so I fixed all issues, but I'm still wondering if Jersey/Jackson or
whatever shouldn't be able to process Arrays of objects as well.

Cheers,
PP

On Tue, May 22, 2012 at 1:33 PM, Paulo Pires <pjpires_at_gmail.com> wrote:

> OK, so retrieving all objects is now working. I just had to replace the
> return type from ISP[] to List<ISP>. Is this supposed to be this way? I
> mean, is it supposed to not support arrays?
>
>
> https://github.com/pires/simple-jersey-rest-app/commit/65bd6af6c879d6e9d0bab5275ace57e7a8c15593
>
> Cheers,
> PP
>
>
> On Tue, May 22, 2012 at 12:51 PM, Paulo Pires <pjpires_at_gmail.com> wrote:
>
>> Retrieving all objects (rest/admin/list) returns the error that I
>> described before.
>>
>> POSTing JSON returns 404 :-s
>>
>> On the other way, getting a single object in JSON works with no problems
>> at all.
>>
>> I've updated the instructions and the code available for testing these 3
>> steps.
>>
>> Cheers,
>> PP
>>
>>
>> On Tue, May 22, 2012 at 11:39 AM, Paulo Pires <pjpires_at_gmail.com> wrote:
>>
>>> 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
>>>
>>
>>
>>
>> --
>> Paulo Pires
>>
>
>
>
> --
> Paulo Pires
>



-- 
Paulo Pires