I'm running a Jersey 2.x application in Tomcat 7. I'm using Jackson 2 with all the correct dependencies.

I wrote a basic test with JerseyTest to check my API. My jackson annotations work fine there. However, as soon as I deploy it in Tomcat, none of my Jackson annotations work.

Another interesting thing is that when I register a custom deserializer on the default Jersey ObjectMapper

private static ObjectMapper createDefaultMapper() {
    final ObjectMapper mapper = new ObjectMapper();
    final SimpleModule module = new SimpleModule();
    module.addDeserializer(MyEntity.class, new MyEntityDeserializer());
    mapper.enable(SerializationFeature.INDENT_OUTPUT);

    mapper.registerModule(module);
    return mapper;
}

The deserializer is picked up in Tomcat. Just with annotations it's not.

The annotations I have tried are

@JsonCreator
@JsonDeserialize
@JsonSetter 

I'm not quite sure where to start debugging this issue.

1 Answers

0
Ortix92 On

Turns out, the entities I was referring to from my webapp were being compiled into a JAR, which were not reloaded by Tomcat. Restarting tomcat solved the issue.