users@jersey.java.net

[Jersey] Re: Deserializing JSON using jersey-client

From: Gili <cowwoc_at_bbs.darktech.org>
Date: Sun, 20 Mar 2011 20:50:20 -0700 (PDT)

Gili wrote:
>
> Hi,
>
> I'm running into problems deserializing a JSON response using
> jersey-client. The resource defines the following method:
>
> @GET
> @Produces(MediaType.APPLICATION_JSON + "; version=1.0")
> public List getClinics()
>
> The client runs the following code:
>
> List result = resource().accept(MediaType.APPLICATION_JSON + ";
> version=1.0").get(new GenericType&lt;List&lt;URI&gt;>()
> {
> });
>
> And Jersey throws the following exception:
>
> SEVERE: A message body reader for Java class
> java.util.List, and Java type java.util.List, and MIME media type
> application/octet-stream was not found
>
> I understand that Jersey is translating List to application/octet-stream
> in spite of the fact that I specified accept() with a different mime type.
> Jackson is serializing List to JSON on the server-side for me. How do I
> get it to deserialize the JSON back into List?
>
> Thank you,
> Gili
>

Upon further investigation, this was caused by this bug:
http://java.net/jira/browse/JERSEY-687

Grizzly was returning requests without a "Content-Type" header so
jersey-client defaulted the type to "application/octet-stream". Now I am
getting:

SEVERE: A message body reader for Java class java.util.List, and Java type
java.util.List, and MIME media type application/json;version=1.0 was not
found

Any idea why Jackson is understands that "application/json;version=1.0" is
JSON when serializing on the server-end but doesn't recognize it on the
client-end?

Thanks,
Gili

--
View this message in context: http://jersey.576304.n2.nabble.com/Deserializing-JSON-using-jersey-client-tp6191049p6191129.html
Sent from the Jersey mailing list archive at Nabble.com.