users@jersey.java.net

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

From: <sebastien.porta_at_s-porta.fr>
Date: Thu, 26 Jan 2012 17:37:28 +0100

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


Le 26/01/2012 16:33, Pavel Bucek a écrit :
> 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
>
> On 1/26/12 3:48 PM, John Yeary wrote:
>> 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
>> <mailto: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.
>>
>>
>


-- 
skype : sebastien.porta
Viadeo : voir mon profil <http://www.viadeo.com/fr/profile/sebastien.porta>