Hi,

I think CXF cannot really know how to convert your custom object to text/plain 
message body.
Only following types will be automatically converted accordingly JAX-RS 2.0 
spec:
byte[], String, InputStream, Reader, File, DataSource, StreamingOutput, 
java.lang.Boolean, java.lang.Character, java.lang.Number

To read/write custom object you need to define own MessageBodyReader and 
MessageBodyWriter; annotate them with @Produces("text/plain ") and 
@Consumes("text/plain"); implement isReadable(), isWritable() and readFrom(), 
writeTo() methods.
These MessageBodyReader, MessageBodyWriter should be registered as providers 
(explicitly or via annotation).

Regards,
Andrei.


> -----Original Message-----
> From: pg [mailto:[email protected]]
> Sent: Mittwoch, 24. September 2014 07:25
> To: [email protected]
> Subject: POJO to be returned with Content-Type: text/plain
> 
> Hi All,
> 
> I am trying to return a POJO object with Content-Type: text/plain. I am 
> getting
> below exception when calling my service:
> 
> No message body writer has been found for response class PojoClassName.
> 
> I was able to return this pojo in JSON format by setting Accept:
> application/json in request header, since I have Provider configured for JSON 
> in
> my cxf-servlet.xml(org.codehaus.jackson.jaxrs.JacksonJsonProvider).
> 
> Is there a need of similar provider to be configured for text/plain content 
> type?
> Or is there any work around for it!!
> 
> Thanks, Puneet.
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/POJO-to-be-
> returned-with-Content-Type-text-plain-tp5749151.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to