7

According to jersey spec, we can use jersey-media-json-jackson to serialize/deserialize json/pojo, however from some thread in StackOverflow, we can use also jackson-jaxrs-json-provider 2.2.3

Can you please advise which one we should use?

Thanks,

duahau
  • 71
  • 1
  • 1
  • 2
  • 1
    i think `jersey-media-json-jackson` is the better choice, i tried `jackson-jaxrs-json-provider` ... but tomcat and jetty fail with `not found for media type=application/json` .. it seems that it is not found automatically on plain servlet-containers – wutzebaer Feb 24 '17 at 21:54
  • This is an old post but @wutzebaer, you were absolutely right. – Jay Feb 25 '20 at 01:59

1 Answers1

5

The right way to do it is to use something like this in your maven configuration (if you are using maven, of course):

...
<properties>
    <jersey.version>2.5.1</jersey.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
...
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey</groupId>
            <artifactId>jersey-bom</artifactId>
            <version>${jersey.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
        <version>${jersey.version}</version>
    </dependency>
    ...

TL;DR - you should use jersey-media-json-jackson 2.5.1

Using the jackson library directly might break some of the auto-discoverable features of jersey.

ingenious
  • 966
  • 10
  • 20
  • 1
    Thank ingenious, i know how to config to make them work, however i'm looking forward the comparaison between them for a good decision. Please note that jackson jaxrs provider 2.2.3 provides auto registration feature as well as jersey media jackson – duahau Feb 23 '14 at 16:02