Serializing Java 8 ZonedDateTime with Jackson and JavaTimeModule

I am trying to use Jackson to serialize and deserialize objects (marshall / unmarshall) from and to JSON. Some of these objects have Java 8 LocalDate and ZonedDateTime. I read here that the best option is to use jackson-datatype-jsr310

serialize / deserialize java 8 java.time using jackson json browser

However, when I try to use this:

ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); 

I get this error:

 java.lang.IllegalAccessError: tried to access method com.fasterxml.jackson.databind.ser.std.StdSerializer.<init>(Ljava/lang/Class;)V from class com.fasterxml.jackson.datatype.jsr310.JavaTimeModule 

Any clue? I am using Jackson 2.6.0, jackson-datatype-jsr310 2.6.0 and using Tomcat 8.

Thanks and best regards

+5
source share
1 answer

In the end, the problem was that I had a different version of Jackson due to a dependency on Jongo. jackson-datatype-jsr310 2.6.0 requires deployment of Jackson 2.6.0 and Jackson 2.4.1.

+6
source

All Articles