I found a workaround. As far as I understood the JSONP stuff tries to serialize 
my sample object as "application/x-javascript" (instead of "application/json"), 
which is not recognized by the default provider.

So I changed the JSONProvider "produceMediaTypes" with 
"application/x-javascript" as well as "application/json". Which works, but I 
don't catch why I have to do so. Also it seems the JSonpInInterceptor has a 
property to change the content type output, but it still outputs 
"application/x-javascript".

Is it the most simple way to obtain a JSONP output?

PS: It would be so nice to have a simple option or annotation to output via 
JSONP :)

Regards,
Jean-Philippe

-----Message d'origine-----
De : CLEMENT Jean-Philippe [mailto:[email protected]] 
Envoyé : lundi 18 juillet 2016 16:38
À : [email protected]
Objet : JSONP -> No message body writer has been found for class

Dear CXF users,

I'm new to CXF and I'm writing a kind of "hello world" JAX-RS service which 
works well with the default JSON output. Following the user doc, I added 
interceptors to allow JSONP output.

JSONP messages now contain the callback method name but its message content is 
"No message body writer has been found for class...". This is strange as if I 
remove the interceptors, the JSON output is correct (the message content is 
serialized properly).

I tried to set the provider to 
"org.apache.cxf.jaxrs.provider.json.JSONProvider" but with no success (same 
output). What's wrong?

Regards,
Jean-Philippe

Reply via email to