See
http://git-wip-us.apache.org/repos/asf/cxf/commit/02ec499a

I'm not sure why it does not work for you, this should work with 3.0.0-milestone1 but also try 3.0.5. Register Jackson on both ends, on the server and on the client, and make sure cxf-rt-rs-extension-providers is not on the classpath, as the server will register it automatically (something I will consider to change for a new trunk)
Sergey
On 15/07/15 17:24, Sergey Beryozkin wrote:
I'll have a look
Sergey
On 15/07/15 16:58, Chris Wolf wrote:
Oh, my bad - I had JacksonJsonProvider not JacksonJaxbJsonProvider.
Well, I just tried both and got the same error.  I have a feeling I
may not be registering it correctly.  The CXF version is
3.0.0-milestone1

Thanks...

On Wed, Jul 15, 2015 at 9:52 AM, Sergey Beryozkin
<sberyoz...@gmail.com> wrote:
Is it JacksonJaxbJsonProvider (you referred to it in the other email) or
JacksonJsonProvider ? And which CXF version ?

Sergey
On 15/07/15 16:47, Chris Wolf wrote:

Ok, I tried to register Jackson, like this:

      public void testGetBookWithJSONDatabinding() {
          List<Object> providers = new ArrayList<Object>();
          // add custom providers if any
          providers.add(JacksonJsonProvider.class);
          WebClient client = WebClient.create(ENDPOINT_ADDRESS,
providers);
          client.accept("application/json");
          client.path("shelf/book");
          Book book = client.query("id", 123L).get(Book.class);
          assertEquals(123L, book.getId());
      }

...but then I got this exception:

ResponseProcessingException: No message body reader has been found for
class CXF_Test.cxf_test.Book, ContentType: application/json

Again, I cannot use spring, so the doc page at:


http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-Jackson


was not too helpful, except pointing out the proper provider class
name.

Thanks,

Chris

On Wed, Jul 15, 2015 at 2:50 AM, Sergey Beryozkin
<sberyoz...@gmail.com>
wrote:

CXF JAX-RS supports registered custom providers, the default
JSONProvider
is
Jettison based and depends on JAXB, register Jackson instead if needed
Sergey
On 15/07/15 02:55, Chris Wolf wrote:


No, it's just a plain POJO with no annotations.  I'm pretty sure I
used Jackson to handle JSON-to-POJO and POJO-to_JSON without
requiring
annotations.  That's not supported in CXF/JAX-RS?

Thanks

Chris

On Tue, Jul 14, 2015 at 2:59 PM, Sergey Beryozkin
<sberyoz...@gmail.com>
wrote:


CXF JSONProvider only supports JAXB annotated beans, with
XmlRootElement,
is
Book.class in your code below a JAXB bean ?
Sergey
On 14/07/15 18:26, Chris Wolf wrote:



Again, referring to the example code at:

https://cwiki.apache.org/confluence/display/CXF20DOC/JAXRS+Testing

This client code works:

        @Test
        public void testGetBookWithProxy() {
            MyJaxrsResource client =
JAXRSClientFactory.create(ENDPOINT_ADDRESS, MyJaxrsResource.class);



WebClient.getConfig(client).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,

Boolean.TRUE);
            WebClient.getConfig(client).setBus(bus);
            Response r = client.getBook("123");
            String bookJSON = r.readEntity(String.class);
            log.info("JAXRS Client result: {}", bookJSON);
        }

...but this client code (which should try to unmarshall to object)
doesn't
work:

        @Test
        public void testGetBookWithWebClient() {
            List<Object> providers = new ArrayList<Object>();
            // add custom providers if any
            providers.add(JSONProvider.class);

            WebClient client = WebClient.create(ENDPOINT_ADDRESS,
providers);
            client.accept("application/json");
            client.path("shelf/book");
            Book book = client.query("id", 123L).get(Book.class);
            assertEquals(123L, book.getId());
        }


The error is:

ResponseProcessingException: No message body reader has been
found for
class CXF_Test.cxf_test.Book, ContentType: application/json

However, as can be seen, I configured the "JSONProvider", which I
thought would unmarshal JSON to POJOs.

Any ideas?



--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com





--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com


Reply via email to