I am trying to write a simple Resteasy client to access mt rest web service. Unfortunately I am getting the error:
Exception in thread "main" org.jboss.resteasy.client.ClientResponseFailure: Unable to find a MessageBodyReader of content-type application/json and type null
at org.jboss.resteasy.client.core.BaseClientResponse.createResponseFailure(BaseClientResponse.java:523)
at org.jboss.resteasy.client.core.BaseClientResponse.createResponseFailure(BaseClientResponse.java:514)
at org.jboss.resteasy.client.core.BaseClientResponse.readFrom(BaseClientResponse.java:415)
at org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:377)
at org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:350)
at org.jboss.resteasy.client.core.BaseClientResponse.getEntity(BaseClientResponse.java:344)
at com.test.client.rest.employee.EmployeeClient.main(EmployeeClient.java:29)
Client code:
ClientRequest request = new ClientRequest(ROOT_URL + "getEmp/GS");
ClientResponse<Employee> resp = request.get(Employee.class);
//Response resp = request.get();
if(resp.getResponseStatus().getStatusCode() == 200)
{
System.out.println("resp ok!!!");
}
Employee e = resp.getEntity(Employee.class);
System.out.println("path:" + e);
Rest Service code:
@GET
@Path("getEmp/{name}")
@Produces("application/json")
public Employee getEmployee(@PathParam("name") String name)
{
if(em.containsKey(name))
return em.get(name);
else
throw new EmployeeNotFoundException("Employee with name '" + name + "' does not exists!");
}
Client code response is ok. i.e. 200. The same url works fine with Mozilla Rest client. Any help would be appreciated