I need to provide a custom Jackson ObjectMapper to Jersey so that I
can register the Joda Time module with it and configure other things
like FAIL_ON_EMPTY_BEANS, etc.
In Jersey 1 I gave a @Provider which implemented
ContextResolver<ObjectMapper> to give my custom OjbectMapper.
In Jersey 2 I bring in the jackson-jaxrs-json-provider artifact which
auto-registers itself with Jersey. However I want to *manually*
register it, so that I can customize it:
public class MyApplication extends ResourceConfig {
public MyApplication() {
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
provider.setMapper(Marshaller.instance.objectMapper);
register(provider);
}
}
My problem is now that I have *two* Jackson providers registered with Jersey:
2014-01-08 23:50:38,823 [main]
org.glassfish.jersey.server.ApplicationHandler:558 INFO Jersey
application initialized.
Root Resource Classes:
...
Message Body Readers:
com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
...
Message Body Writers:
com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
...
What's the right way to do this? I either want to get access to the
Jackson provider that Jersey auto-discovered (so that I can change its
ObjectMapper) or I want to stop the auto-discovery so that I can
register my own Jackson provider.
Mike