title: How to register jackson json provider for cxf jax-rs 2.0 client?
body: <p>I have a JAX-RS client that's making a simple GET request.  I'm using the CXF implementation and Spring for DI.  The call is successfull and I get a response code of 200 back.  But I'm getting an error when reading the response into my POJO.</p>
  
  <p><strong>Exception:</strong></p>
  
  <pre><code>[2015-05-08 16:11:55,457][ERROR][org.apache.cxf.jaxrs.utils.JAXRSUtils]: No message body reader has been found for class com.voya.refapp.domain.Customer, ContentType: application/json
  [2015-05-08 16:11:55,468][ERROR][com.voya.refapp.service.CustomerServiceImpl]: filterByName() - Exception occurred
  javax.ws.rs.client.ResponseProcessingException: No message body reader has been found for class com.voya.refapp.domain.Customer, ContentType: application/json
      at org.apache.cxf.jaxrs.impl.ResponseImpl.reportMessageHandlerProblem(ResponseImpl.java:433) ~[cxf-rt-frontend-jaxrs-3.0.4.jar:3.0.4]
      at org.apache.cxf.jaxrs.impl.ResponseImpl.doReadEntity(ResponseImpl.java:384) ~[cxf-rt-frontend-jaxrs-3.0.4.jar:3.0.4]
  </code></pre>
  
  <p><strong>Code:</strong>
  </p>
  
  <pre class="lang-java prettyprint-override"><code>Client client = ClientBuilder.newClient();
  WebTarget target = client.target("http://localhost:8080/rest").path("customers/1");
  Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON_TYPE);
  Response response = builder.get();  // Successful
  Customer customer = response.readEntity(Customer.class);  // Fails
  </code></pre>
  
  
  
  <p>I have the below dependency as suggested in <a href="https://stackoverflow.com/a/18755789/1128163">this answer</a> in my classpath, it doesn't seem to be picked up automatically.</p>
  
  <pre class="lang-java prettyprint-override"><code>    &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.jaxrs&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-jaxrs-json-provider&lt;/artifactId&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>I also tried registering the json provider when creating the client:</p>
  
  <pre class="lang-java prettyprint-override"><code>Client client = ClientBuilder.newClient().register(new JacsksonJsonProvider());
  </code></pre>
  
  <p>and</p>
  
  <pre class="lang-java prettyprint-override"><code>Client client = ClientBuilder.newClient().register(JacsksonJsonProvider.class);
  </code></pre>
  
  <p>But none of these options worked too. I got a different exception when I registered the json provider using one of the options above:</p>
  
  <pre class="lang-java prettyprint-override"><code>javax.ws.rs.client.ResponseProcessingException: Problem with reading the data
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>Registering the json provider worked fine using <code>ClientBuilder.newClient().register(JacsksonJsonProvider.class)</code>.  The issue was with the data (like the exception above clearly states.. I feel silly now :().  I had boolean field in the json named "active", but it was called "isActive" in the POJO. Once I added the annotation <code>@JsonProperty("active")</code> to the field in POJO, it started working fine</p>