I just setup a simple test project to see how to implement MessageBodyWriter.
But I keep getting "No message body writer has been found for response class
Customer" error.
Can someone give me some help ?
These are what I have:
1. properties file
openejb.cxf.jax-rs.providers = com.mycompany.MyMessageBodyWriter
com.mycompany.Customer.providers = com.mycompany.MyMessageBodyWriter
openejb.jaxrs.providers.auto = true
2. Provider
package com.mycompany;
...
@Produces("my/type")
@Provider
public class MyMessageBodyWriter implements MessageBodyWriter<Customer> {
@Override
public long getSize(Customer obj, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType) {
return -1;
}
@Override
public boolean isWriteable(Class<?> type, Type genericType,
Annotation annotations[], MediaType mediaType) {
return true;
}
@Override
public void writeTo(Customer target, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String,Object> httpHeaders, OutputStream
outputStream)
throws IOException {
outputStream.write("Test".getBytes());
outputStream.flush();
}
}
3. Rest service
@Path("/pojo3")
public class Test3 {
@GET
@Produces("my/type")
public Customer pojo3() {
Customer c = new Customer();
...
return c;
}
}
--
View this message in context:
http://openejb.979440.n4.nabble.com/Simple-MessageBodyWriter-Testing-with-No-message-body-writer-has-been-found-for-response-class-error-tp4657558.html
Sent from the OpenEJB User mailing list archive at Nabble.com.