Use new version of Jackson JSON with Jersey

Guice Module:

import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import com.google.inject.Singleton;
import com.sun.jersey.guice.JerseyServletModule;
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
 
public final class JerseyModule extends JerseyServletModule
{
   @Override
   protected void configureServlets()
   {
      bind(JacksonJaxbJsonProvider.class).in(Singleton.class);
      filter("/*").through(GuiceContainer.class);
   }
}

And the Maven pom:

<dependency>
   <groupId>com.fasterxml.jackson.jaxrs</groupId>
   <artifactId>jackson-jaxrs-json-provider</artifactId>
   <version>2.0.5</version>
</dependency>

One thought on “Use new version of Jackson JSON with Jersey

  1. You made my day!
    After upgrading jackson from 1.8.5 to new one – 2.0.5 I am having problems with Jersey (1.8). Jersey is ignoring @JsonInclude annotations (for example it returns nulls for fields with Include.NON_NULL). after adding jackson-jaxrs-json-provider dependency, everything is ok.
    There is very small amount of informations about this new version of Jackson – thanks a lot for this short post!

Leave a Reply

Your email address will not be published. Required fields are marked *