users@jersey.java.net

[Jersey] Re: Programmatically configure Jackson POJO mapping?

From: Noah White <emailnbw_at_gmail.com>
Date: Wed, 20 Feb 2013 23:42:24 -0500

OK good to know.

My simple Jersey 2 test project is failing to serialize a POJO into JSON with:

MessageBodyWriter not found for media type=application/json, type=class example.Movie, genericType=class example.Movie
Is the Jackson 2 Jax-rs provider not bundled with GF4? With GF v3.1.2.2 the provider was JacksonProviderProxy was it not? I don't see that in the GF4 distro.

Thanks,

-Noah

On Feb 20, 2013, at 1:10 PM, Tatu Saloranta <tsaloranta_at_gmail.com> wrote:

> On Wed, Feb 20, 2013 at 8:38 AM, Noah White <emailnbw_at_gmail.com> wrote:
>> All the examples I have seen configure Jackson POJO mapping (non-JAXB) using the web.xml.
>>
>> Is there a way to do this programmatically?
>
> Yes, ObjectMapper is registered using standard JAX-RS provider mechanism.
> Same for Jackson JAX-RS provider. So web.xml is just one way.
>
> And in fact, Jackson 2.0 JAX-RS provider auto-registers, if added in classpath.
>
> -+ Tatu +-