users@jersey.java.net

[Jersey] Beware of JacksonFeature in Jersey

From: Robert DiFalco <robert.difalco_at_gmail.com>
Date: Fri, 13 Dec 2013 19:03:50 -0800

Just a heads up so that people don't have to deal with the craziness I just
went through.

Setting up Jersey 2.4.1 to work with Jackson is exceedingly simple, that is
unless you read the Jersey tutorials and documentation.

The JacksonFeature will pull in Jackson 1.9! I don't really think anyone
uses this version anymore, most of us use fasterxml 2.x.

Just do this:

public class RestApplication extends ResourceConfig {
    public RestApplication() {
        packages( "com.myapp.rest", "com.fasterxml.jackson.jaxrs.base" );
    }
}

Then add this to your pom.xml:

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.jaxrs</groupId>
            <artifactId>jackson-jaxrs-json-provider</artifactId>
            <version>${jackson.version}</version>
        </dependency>

Completely forget about JacksonFeature AND DO NOT PUT THIS IN YOUR pom.xml:

        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
            <version>${jersey.version}</version>
        </dependency>

It's super simple, everyone seems to make it complicated. Now, listen, this
is trial and error so maybe there is a reason for all of the complexity
that the Jersey docs suggest for Jackson or all the blogs and stack
overflow answers. But Just the two jackson pom entries and the fasterxml
provider path is all I needed to use Jackson 2.3.0.