I'm using Jersey 1.17.1 with Jackson 2.2.1.
It seems like Jackson switched packages from org.codehaus
to com.fasterxml
. I have all my code configured properly and using the latest jackson. However, it seems like Jersey is still pulling in org.codehaus.jackson
. Is there any way to mitigate this or should I stick with the codehaus
packages until jersey is upgraded to use the fasterxml
packages?
The older Jackson libraries are being pulled in as dependencies of the jersey-json artifact. When
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.17</version>
</dependency>
is included in your POM you will automatically get versions of the org.codehaus.jackson libraries included in your project. Unfortunately, jersey-json itself has link time dependencies on the Jackson classes, so you can't simply use exclusions. What you want do to instead is omit it entirely. It's really a kind of wrapper library around a bunch of JSON libraries that you do not necessarily need. Once removed, you can add dependencies for the Jackson 2.2.1 libraries and JAX-RS provider:
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.2.1</version>
</dependency>
Note that with jersey-json removed you no longer have a Stax2, Jettison, or JAXB provider. If you need those then you will have to locate and add dependencies for them manually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With