I have a jaxrs client configured like this:
<jaxrs:client id="opaRestProxy" name="opaRestProxy"
address="${endpoint}" serviceClass="com.test.RestProxy"
inheritHeaders="true" threadSafe="true">
<jaxrs:headers>
<entry key="Accept" value="application/json" />
<entry key="Content-Type" value="application/json" />
</jaxrs:headers>
</jaxrs:client>
But when I send a request I get the following exception:
Caused by: org.apache.cxf.interceptor.Fault: .No message body writer has been found for class : class com.test.RequestObject, ContentType : application/json.
at org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.handleMessage(ClientProxyImpl.java:646)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:527)
... 47 more
My RestProxy class looks like this:
@Component
public interface RestProxy {
@POST
@Path("/getSomething")
String getSomething(RequestObject RequestObject);
}
If you are using Jackson JSON library you need to add these xml tags to your application context.
<jaxrs:providers>
<bean id="jacksonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
</jaxrs:providers>
If you are using any other library add that bean to the providers tag. Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With