title: Unable to read Java object from response in Jersey 2
body: <p>I'm migrating my existing Jersey 1.x code to 2.x and I'm facing issue when executing the below code.</p>
  
  <p>Jersey code:</p>
  
  <pre><code>      public String getEmployeeDetail(long empId) {
          String empName = null;
          String url = String.format("%s/%d/", "http://localhost:8080/emp/detail", empId);
          UriBuilder builder = UriBuilder.fromUri(url);
          WebTarget webtarget = client.target(builder.build());
          EmployeeDetail empDetail = webtarget.request("application/x-java-serialized-object").header("Cache-Control", "no-cache").get(EmployeeDetail.class);
          if(empDetail.getName() != null) {
            empName = empDetail.getName();
          }
          return empName;
        }
  </code></pre>
  
  <p>EmployeeDetail class:</p>
  
  <pre><code>      @XmlRootElement(name="employeeDetail")
        public class EmployeeDetail {
          String name;
          String age;
          public String getName() {
            return name;
          }
          public void setName(String name) {
            this.name = name;
          }
          public String getAge() {
            return age;
          }
          public void setAge(String age) {
            this.age = age;
          }
        }
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>    org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=application/x-java-serialized-object;class=com.client.response.EmployeeDetail, 
      type=class com.client.response.EmployeeDetail, genericType=class com.client.response.EmployeeDetail.
  </code></pre>
  
  <p>After some research , tried the following and it resulted the same error.</p>
  
  <pre><code>    Response response = webtarget.request("application/x-java-serialized-object").header("Cache-Control", "no-cache").get();
      System.out.println("response.getStatus()==&gt;&gt;" + response.getStatus());   output =============&gt;&gt;&gt; 200
      EmployeeDetail empDetail = response.readEntity(new GenericType&lt;EmployeeDetail&gt;(){});
  </code></pre>