Has anybody managed to use jackson 2.0 with Jersey 1.12. It will be very interesting to know. We have to use jackson 1.9.x all over the place, just because jersey has jackson so strongly coupled. From what I see even jersey 2.0M3 is still using jackson 1.9.2. So it seems there is no point to wait for jersey team to do it in near future.
3 Answers
Custom provider works; and "official" Jackson 2.0 JSON provider project does the same, with bit more features (ability to use @JsonView
annotation and a few others on resource methods).
This is one of nice things with JAX-RS: everything is modular, and adding new improved providers is very easy.

- 113,358
- 34
- 211
- 239
-
So shall I just include the jar? What is required to force Jersey to use this provider? – husayt May 20 '12 at 21:56
-
You can try just including it -- 2.0 does have META-INF/services -- but if that does not work, need to register provider in `Application` implementation. – StaxMan May 21 '12 at 21:37
-
2What is strange, that works, even with PojoMapping feature turned on in Jersey. – husayt May 24 '12 at 13:08
-
Not all that strange due to registration: 1.x did not have it (for fear it'd conflict with legacy settings). So with 2.x PojoMapping should not be needed... one can still explicitly replace it with other providers. – StaxMan May 24 '12 at 17:51
-
1With Jackson 2.2 the "official" provider changed to [jackson-jaxrs-providers](https://github.com/FasterXML/jackson-jaxrs-providers) and it is indeed "plug and play", i.e. just add it to the classpath and you'll get a POJO-to-JSON mapping working with default settings. – rustyx Oct 14 '13 at 15:04
I've Jackson 2.0 and Jersey 1.12 in my project. I had not any problems with it, but probably reason is that I had custom Provider with some additional ObjectMapper settings. Simplified version:
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import com.fasterxml.jackson.databind.ObjectMapper;
@Provider
public class ObjectMapperProvider implements ContextResolver<ObjectMapper> {
private final ObjectMapper defaultObjectMapper;
public ObjectMapperProvider() {
defaultObjectMapper = new ObjectMapper();
}
@Override
public ObjectMapper getContext(Class<?> type) {
return defaultObjectMapper;
}
}

- 1,986
- 1
- 20
- 46
-
7Did you have to do anything special to get Jersey to use this provider? I'm trying to migrate from Jackson 1.9 to 2.0 (as detailed in [this question](http://stackoverflow.com/questions/15865896/migrate-a-jackson-objectid-serializer-from-jackson-1-9-to-2-0)) and my ContextResolver-implementation isn't being used. – Eyal Apr 10 '13 at 08:15
If you're trying to use JsonView with Jersey, you must use org.codehaus.jackson.map.annotate.JsonView if you use the method 2.2 on here: http://wiki.fasterxml.com/JacksonFAQJaxRs
If you want to use JsonView from com.fasterxml, you must use the general method (1) on that page.

- 1