title: Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance
body: <p>I have written java web application (front-end) using JSF.</p>
  
  <p>I use <code>Jersey RESTful Web Services framework</code> version <code>1.8</code> to send data to the back-end. </p>
  
  <p>The back-end is <code>jax-rs</code> RESTful Web Service using <code>spring boot</code>.</p>
  
  <p>In front-end I have <code>GET</code> methods (Using <code>Jersey-client</code>), these methods work without any problem.</p>
  
  <p>When I post JSON data using the <code>Postman</code> software it is also working without any problem, but when I sent my <code>Customer</code> object using front-end application (Using Jersey client) it gives me this error:</p>
  
  <pre><code>    WARN 2156 --- [io-8089-exec-53] .w.s.m.s.DefaultHandlerExceptionResolver :Failed
  to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: 
  JSON parse error: Cannot construct instance of `com.example.demo.model.Customer` 
  (although at least one Creator exists): no String-argument constructor/factory
   method to deserialize from String value 
   ('{"id":0,"name":"abc","city":"def","contactNum":334455}'); nested exception is 
   com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct 
   instance of `com.example.demo.model.Customer` (although at least one Creator exists):
   no String-argument constructor/factory method to deserialize from String value 
   ('{"id":0,"name":"abc","city":"def","contactNum":334455}')
  </code></pre>
  
  <p>Here is my front-end method for send data.</p>
  
  <pre><code>public static void saveCustomer(Customer customer) throws IOException {
  
      Gson gson = new Gson();
      String custJson = gson.toJson(customer);
      System.out.println(custJson);
  
      Client create = Client.create();
      WebResource webResorce = create.resource("http://localhost:8089/springHibernate/addCus");
      ClientResponse response = webResorce.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).post(ClientResponse.class, custJson);
  
      if (response.getStatus() != 201) {
          response.close();
          throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
      }
  
      System.out.println("Output from Server .... \n");
      String output = response.getEntity(String.class);
      System.out.println(output);
      response.close();
  
  }
  </code></pre>
  
  <p>Here is the back-end service </p>
  
  <pre><code>@RequestMapping(value = "/addCus", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
  public Customer process( @RequestBody Customer cus) throws Exception {
  
      Customer saveCus = customerSrvice.saveCus(cus);
      return saveCus;
  }
  </code></pre>
  
  <p><strong>EDIT</strong> The <code>Customer</code> class</p>
  
  <pre><code>package com.example.demo.model; 
  
  @Entity 
  @Table(name="customer")
  public class Customer implements Serializable { 
      private static final long serialVersionUID = 1L; 
  
      @Id 
      @GeneratedValue(strategy = GenerationType.AUTO ) 
      private int id;
  
      @Column(name = "name") 
      private String name; 
  
      @Column(name = "city") 
      private String city; 
  
      @Column(name = "contactNum") 
      private int contactNum;
  
  
      public Customer() { } 
      public Customer(String name, String city, int contactNum) { /**/ } 
      public Customer(int id, String name, String city, int contactNum) { /**/ } 
  
  }
  </code></pre>
  
  <p>The <strong>front-end</strong> pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.keylesson.jsf22&lt;/groupId&gt;
  &lt;artifactId&gt;PrimeFaces-Hello-World-Example&lt;/artifactId&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;version&gt;1.0&lt;/version&gt;
  &lt;name&gt;PrimeFaces-Hello-World-Example&lt;/name&gt;
  &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
  &lt;dependencies&gt;
  
      &lt;!-- JSF2.2 dependency --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
          &lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
          &lt;version&gt;2.2.8&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
          &lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;
          &lt;version&gt;2.2.8&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
          &lt;version&gt;3.1.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
          &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
          &lt;version&gt;2.2.1-b03&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- PrimeFaces dependency --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.primefaces&lt;/groupId&gt;
          &lt;artifactId&gt;primefaces&lt;/artifactId&gt;
          &lt;version&gt;6.2&lt;/version&gt;
          &lt;type&gt;jar&lt;/type&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-client&lt;/artifactId&gt;
          &lt;version&gt;1.9&lt;/version&gt;
          &lt;type&gt;jar&lt;/type&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-json&lt;/artifactId&gt;
          &lt;version&gt;1.8&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- this dependancy help to map json to java object dependency --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.owlike&lt;/groupId&gt;
          &lt;artifactId&gt;genson&lt;/artifactId&gt;
          &lt;version&gt;0.99&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
          &lt;artifactId&gt;gson&lt;/artifactId&gt;
          &lt;version&gt;2.8.2&lt;/version&gt;
          &lt;type&gt;jar&lt;/type&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p></p>
  
  <p>The <strong>Back-end</strong> pom.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.demo&lt;/groupId&gt;
      &lt;artifactId&gt;springHibernate&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;name&gt;springHibernate&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.0.0.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
                  &lt;dependency&gt;
              &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
              &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>