Skip to content
Advertisement

ERROR: org.codehaus.jackson.map.JsonMappingException

I’m using lombok + Java to otimizate the application. The class has the tags @Data , @EqualsAndHashCode(callSuper = false), @NoArgsConstructor, @AllArgsConstructor e @Builder before signature’s class. When I run, It shows the error below:

ERROR:

org.apache.cxf.jaxrs.JAXRSRuntimeException: org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type [simple type, class java.time.LocalDateTime]: can not instantiate from JSON object (need to add/enable type information?) at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1@25e15ce5; line: 1, column: 188] at org.apache.cxf.jaxrs.utils.JAXRSUtils.toJAXRSRuntimeException(JAXRSUtils.java:1906) at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.convertExceptionToResponseIfPossible(JAXRSInInterceptor.java:276)

CLASS:

JavaScript

I thougth this lombok’s tags are enough. Does anyone have any idea?

Advertisement

Answer

  1. You are using a very old Jackson version.
  2. To make Jackson work with Java 8 time, you need to add jackson-datatype-jsr310 dependency and register module in ObjectMapper:
JavaScript

Complete working example with current Jackson version:

JavaScript

Dependencies:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement