users@jersey.java.net

MediaType Delegate Null Pointer

From: Tom Barber <tom_at_analytical-labs.com>
Date: Mon, 20 Sep 2010 22:09:12 +0100

Okay moving on from last night, I'm an OSGI newb and didn't realise you had to activate Jersey Core and Jersey Client which i have now done but the same line is still failing me:

java.lang.NullPointerException
        at javax.ws.rs.core.MediaType.valueOf(MediaType.java:119)
        at com.sun.jersey.api.client.PartialRequestBuilder.type(PartialRequestBuilder.java:92)
        at com.sun.jersey.api.client.WebResource.type(WebResource.java:304)

I've been looking at this for ages now and can't for the life of me work out what it is.

Any pointers folks?

Thanks

Tom

Begin forwarded message:

> From: Tom Barber <tom_at_wamonline.org.uk>
> Date: 19 September 2010 21:54:35 GMT+01:00
> To: users_at_jersey.dev.java.net
> Subject: MediaType Delegate is null.
>
> Hi Guys,
>
> I'm trying to create a jersey client osgi bundle for use in Apache Sling.
>
> My code is pretty straightforward
>
> r = client.resource("http://localhost:8888/dependencyApp/rest/admin/session");
> Builder test = r.accept(MediaType.APPLICATION_JSON);
> ClientResponse response = test.post(ClientResponse.class);
> return response.getEntity(SessionObject.class);
>
> But when I try to get the entity I the delegate variable in MediaType is always null so the valueOf call fails.
>
> I've searched around, and I saw that previously you may have had to include the jersey-server package as well so I did that. Both client and server are 1.4 but I always get an NPE for the delegate.
>
> Any pointers?
>
> Thanks
>
> Tom