users@jersey.java.net

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

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Fri, 29 Apr 2011 16:48:31 +0200

Hi Mohan,

If you do not need to rely on JAXB features when generating JSON,
you may just want to switch to using the JSON POJO mapping feature (see [1])
in Jersey, and you should be getting the JSON content all right.

~Jakub

[1]http://jersey.java.net/nonav/documentation/latest/json.html#d4e894

On 04/21/2011 02:18 AM, Mohan KR (mkannapa) wrote:
>
> Greetings,
>
> 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
>
> something.
>
> I'm using jersey 1.6. Thanks in advance.
>
> Thanks!
>
> Regards,
>
> Mohan KR
>