[Jersey] CustomResolver (Marshaller) dual content type xml and json

From: Mohan KR \(mkannapa\) <"Mohan>
Date: Wed, 20 Apr 2011 19:18:44 -0500


  My core problem is I need to support XML and JSON in my responses. I have
JAXB annotated POJOS, and

  my resource method's have the appropriate @Produces Annotation. With this
setup everything appears

  to be working fine, using curl to send separate requests with the
appropriate Accept headers.


  After, making sure things were working, I need to set some Marshaller
Properties, and it appears that the

  recommended approach is to use the ContextResolver<Marshaller> approach. I
did that and registered it

  as a provider to the runtime. Now, XML content type is working fine, but
JSON is broken I get no content.

  Do I need to implement a JSONMarshaller too? Although my ContextResolver
is being called when I make

  the request with application/xml and application/json. Don't know whether
it is a bug or maybe I'm missing



  I'm using jersey 1.6. Thanks in advance.






Mohan KR