I'm using Jackson (in Jersey) to serialize entities, and I'm migrating from Jackson 1.9 to 2.0. I followed this guide, and at first it seemed like everything worked out easily.
But a closer look reveals that Jackson 1.9 is still being used to serialize my responses, and therefore ignoring my (migrated) Jackson 2.0 annotation. You can see which annotations I'm using in the following code fragment:
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public abstract class IdEntity {
@Id
@JsonDeserialize(using = ObjectIdJsonDeserializer.class)
protected ObjectId id;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonSerialize(using = ObjectIdJsonSerializer.class)
public ObjectId getId() {
return id;
}
public void setId(ObjectId id) {
this.id = id;
}
@JsonIgnore
public String getIdAsString() {
return id == null ? "" : id.toString();
}
My @JsonIgnore getters are getting serialized, and my ObjectIdJsonSerializer isn't being used for the ObjectId field.
In debug I can see that the ObjectMapper being used is from 1.9.
I've removed all the direct maven dependencies to Jackson 1.9, and tried adding exclusions to jersey-json, to prevent it from pulling in Jackson 1.9. But I can't get rid of it entirely (by putting an exclusion to all the codehaus.jackson stuff in my dependency management) because I'm also using Spring AMQP, which needs Jackson 1.9.
Any ideas on how to manage this? Has anyone encountered / solved a similar problem? How do I force Jersey to use Jackson 2.0?