I have a simple service that is annotated with JAX-RS annotations and includes @Produces("application/json") annotation @Produces("application/json") . When registering the service, I set the following properties (I use DS, but it does not matter):
service.exported.interfaces -> * service.exported.configs -> org.apache.cxf.rs org.apache.cxf.rs.address -> myURI
When I launch my application, I can click the URL, but my browser returns:
No message body writer has been found for response class MyClass.
My OSGi console displays:
Jan 11, 2012 2:29:48 PM org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor writeResponseErrorMessage WARNING: No message body writer has been found for response class MyClass.
I read the documentation and thought maybe I needed to register a JSON provider. In the activation activator, I added:
bundleContext.registerService(new String[] { "javax.ws.rs.ext.MessageBodyReader", "javax.ws.rs.ext.MessageBodyWriter" }, new org.apache.cxf.jaxrs.provider.JSONProvider(), null);
but it didn’t matter.
How to fix "There is no message body writer for the MyClass response class." error message?
source share