users@jersey.java.net

[Jersey] Re: ERROR on .getEntity(String.class);

From: John Yeary <johnyeary_at_gmail.com>
Date: Thu, 26 Jan 2012 09:48:22 -0500

Try adding .type(MediaType.APPLICATION_JSON)

I think that is missing.

____________________________

John Yeary
____________________________

<http://javaevangelist.blogspot.com/> <https://twitter.com/jyeary>
<http://www.youtube.com/johnyeary>
  <http://www.linkedin.com/in/jyeary>
<https://plus.google.com/112146428878473069965>
  <http://www.facebook.com/jyeary>
<http://feeds.feedburner.com/JavaEvangelistJohnYearysBlog>
  <http://netbeans.org/people/84414-jyeary>
____________________________

"Far better it is to dare mighty things, to win glorious triumphs, even
though checkered by failure, than to take rank with those poor spirits who
neither enjoy much nor suffer much, because they live in the gray twilight
that knows not victory nor defeat."
-- Theodore Roosevelt



On Wed, Jan 25, 2012 at 5:17 PM, <sebastien.porta_at_s-porta.fr> wrote:

> Hi there,
>
> I have a problem on Android with jersey-client...
> I'm using jersey-core-1.11 and jersey-client-1.11
> I'm trying to execute this code :
>
> WebResource webResource = Client.create().resource(nodeEntryPointUri);
> ClientResponse response = webResource.path("signalised")
>
> .queryParam("representationJSON", object.toString())
> .accept("application/json")
> .get( ClientResponse.class );
> Log.d(TAG,"object " + response);
> String output = response.getEntity(String.class);
>
> But on the last line i have this error :
> 01-25 21:52:46.273: E/AndroidRuntime(233): Uncaught handler: thread
> main exiting due to uncaught exception
> 01-25 21:52:46.282: E/AndroidRuntime(233):
> java.lang.NullPointerException
> 01-25 21:52:46.282: E/AndroidRuntime(233): at
> javax.ws.rs.core.MediaType.valueOf(MediaType.java:119)
> 01-25 21:52:46.282: E/AndroidRuntime(233): at
> com.sun.jersey.api.client.ClientResponse.getType(ClientResponse.java:61
> 5)
> 01-25 21:52:46.282: E/AndroidRuntime(233): at
> com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:
> 532)
>
> Is there a solution ? can someone help me ?
> Thx in advance.
>