Discussion:
ERROR on .getEntity(String.class);
s***@public.gmane.org
2012-01-25 22:17:46 UTC
Permalink
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.
John Yeary
2012-01-26 14:48:22 UTC
Permalink
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
Post by s***@public.gmane.org
Hi there,
I have a problem on Android with jersey-client...
I'm using jersey-core-1.11 and jersey-client-1.11
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);
01-25 21:52:46.273: E/AndroidRuntime(233): Uncaught handler: thread
main exiting due to uncaught exception
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
532)
Is there a solution ? can someone help me ?
Thx in advance.
Pavel Bucek
2012-01-26 15:33:07 UTC
Permalink
Looks like this is popular question lately, there already is a solution,
but is not very nice, see this thread:
http://jersey.576304.n2.nabble.com/java-lang-NullPointerException-on-Android-td4212447.html

I think we should make some android friendly bundle - can you please
file new RFE?

Thanks,
Pavel
Post by John Yeary
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
Hi there,
I have a problem on Android with jersey-client...
I'm using jersey-core-1.11 and jersey-client-1.11
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);
01-25 21:52:46.273: E/AndroidRuntime(233): Uncaught handler: thread
main exiting due to uncaught exception
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
532)
Is there a solution ? can someone help me ?
Thx in advance.
s***@public.gmane.org
2012-01-26 16:37:28 UTC
Permalink
Thx for your both answers I'll try it now.

And i've just filed a RFE (http://java.net/jira/browse/JERSEY-930).
Hope that's good.

Sebastien
Post by Pavel Bucek
Looks like this is popular question lately, there already is a
http://jersey.576304.n2.nabble.com/java-lang-NullPointerException-on-Android-td4212447.html
I think we should make some android friendly bundle - can you please
file new RFE?
Thanks,
Pavel
Post by John Yeary
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
Hi there,
I have a problem on Android with jersey-client...
I'm using jersey-core-1.11 and jersey-client-1.11
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);
01-25 21:52:46.273: E/AndroidRuntime(233): Uncaught handler: thread
main exiting due to uncaught exception
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
532)
Is there a solution ? can someone help me ?
Thx in advance.
--
skype : sebastien.porta
Viadeo : voir mon profil <http://www.viadeo.com/fr/profile/sebastien.porta>
Loading...