users@jersey.java.net

[Jersey] Re: Proper Configuration of Jackson 2.0 in Jersey 2.6

From: Ted M. Young [_at_jitterted] <tedyoung_at_gmail.com>
Date: Mon, 24 Feb 2014 16:34:17 -0800

Glad it's working, Robert. Are the docs around this still wrong? If so,
let's file a JIRA to get that fixed.

;ted



On Mon, Feb 24, 2014 at 2:02 PM, Robert DiFalco <robert.difalco_at_gmail.com>wrote:

> Step 2 should no longer be required in Jersey 2.6 if you are using Jackson
> 2.3x.
>
>
> On Mon, Feb 24, 2014 at 11:59 AM, <tommif_at_iki.fi> wrote:
>
>> Hopefully I'm not talking too much bull here. Let's try:
>>
>> For future reference to any hapless soul trying to meddle with Jersey's
>> twisted magic:
>>
>> The center ingredient to customizing Jackson's ObjectMapper is to make
>> Jersey use Jackson's own JAX-RS <-> Jackson MessageBodyReader and
>> MessageBodyWriter instead of it's own.
>> - Jackson's JAX-RS integration looks up the ObjectMapper instance from
>> ContextResolvers.
>> - Jersey-provided Jackson integration doesn't, and instead instantiates
>> it's own, leaving no room for customizing the ObjectMapper.
>>
>> Step 1. Implement ContextResolver<ObjectMapper> to provide your
>> customized ObjectMapper instance and register it with Jersey.
>> Step 2. Register
>> com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider with Jersey.
>> Step 3. Done.
>>
>>
>> On 24.2.2014 19:16, Robert DiFalco wrote:
>> > I'm not really clear on the correct path to do this in 2.6. I had to
>> > go through a lot in 2.5x. Am I to understand that I know longer use
>> > JacksonFeature? That I only need to declare a ContextResolver for my
>> > ObjectMapper instance? If so this doesn't seem to be working for me.
>> > Maybe I need to register the my ContextResolver explicitly (not just
>> > annotated with Provider)? Or maybe I'm missing a dependency? I assumed
>> > I could now exclude media jackson json.
>> >
>> > The Jersey documentation is not up to date on this matter and still
>> > seems to be advising on the method used in 2.5 to configure Jackson 1.x.
>> >
>> > TIA
>>
>>
>