I’m create a CXF client proxy using JAXRSClientFactory, from an interface of my RESTful web service.
My interface represents CRUD operations, so my create takes in an custom Object and create a DB entry from it. When I pass my object to the create method, I would get this:
org.apache.cxf.jaxrs.client.ClientWebApplicationException: org.apache.cxf.interceptor.Fault: .No message body writer has been found for class : class com.example.Calss, ContentType : application/json.
I resolved this by adding a provider list with JacksonJsonProvider to the JAXRSClientFactory.create method, which resolved marshalling the object.
Then I attempted to perform the Read operation, which returns a Response object who’s entity is a custom Object. When I attempt to read, I get this error:
org.apache.cxf.jaxrs.client.ClientWebApplicationException: .Problem with reading the response message, class : class javax.ws.rs.core.Response, ContentType : application/json.
I can resolve this by removing the provider from my JAXRSClientFactory.create, but this causes the Create operation to fail.
I cannot seem to resolve this issue(while using the same client object). Has anyone else encountered this? What am I doing wrong?
This issue stems from using Jackson as the JSON mapper. On my interface definition, I’m returning a
Responseobject, which Jackson/CXF doesn’t know how to handle, so Jackson doesn’t write it.The solution was this: