Hello,
You need to put JacksonFeature into Your ClientConfig, before creating new
client.
instead of
Client client = ClientBuilder.newClient();
call
ClientConfig cc = new ClientConfig().register(new JacksonFeature());
Client client = ClientBuilder.newClient(cc);
You can see it in Jersey examples
https://github.com/jersey/jersey/tree/master/examples/json-jackson/src.
I've also added small sample with generics in this commit
https://github.com/aleskiewicz/AsycJsonView/commit/358574765ca3f76e21344fbd7b84260ce6f215e9
.
2013/4/29 agks mehx <agksmehx_at_gmail.com>
> The the following Exception is thrown by running the code that follows it.
> What do I need to do to get JSON work properly in the client?
>
> Exception in thread "main"
> org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException:
> MessageBodyReader not found for media type=application/json, type=class
> com.younum.test.foo.User, genericType=class com.younum.test.foo.User.
> at
> org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:173)
>
> -----------------
>
> package com.example.test.foo;
>
> import javax.ws.rs.client.Client;
> import javax.ws.rs.client.ClientBuilder;
> import javax.ws.rs.client.WebTarget;
> import javax.ws.rs.core.MediaType;
> import javax.xml.bind.annotation.XmlRootElement;
>
> @XmlRootElement
> public class User {
>
> public String id;
> public String name;
>
> public static void main (String [] args) {
> Client client = ClientBuilder.newClient();
> WebTarget web_target = client
> .target("https://graph.facebook.com/skra95");
> User me = web_target
> .request()
> .accept(MediaType.APPLICATION_JSON_TYPE)
> .buildGet()
> .property("access_token", "a_valid_access_token")
> .invoke(User.class);
> System.out.println(me);
> }
>
> }
>
>
--
Best regards
Andrzej Le¶kiewicz