Facing exception "com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.LocalDate` not supported by default" after updating to JBoss EAP 7.4.x

Solution Unverified - Updated -

Issue

  • Facing exception "com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type java.time.LocalDate not supported by default" after updating to JBoss EAP 7.4.x:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.LocalDate` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling
    at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)
    at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1276)
    at com.fasterxml.jackson.databind.ser.impl.UnsupportedTypeSerializer.serialize(UnsupportedTypeSerializer.java:35)
    at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
    at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
    at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4487)
    at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3742)
    ...(snip)..
  • We have the following code and the same application works fine in the previous versions (like EAP 7.2.x and EAP 7.3.x):
import java.time.LocalDate;
import com.fasterxml.jackson.databind.ObjectMapper;

...(snip)...

    ObjectMapper mapper = new ObjectMapper();
    LocalDate localDate = exampleObject.getLocalDate();
    System.out.println("LocalDate = " + mapper.writeValueAsString(localDate));
import java.time.LocalDate;

public class ExampleObject {

   private LocalDate localDate;

   public ExampleObject() {
         this.localDate = LocalDate.now();
     }

   public LocalDate getLocalDate() {
         return localDate;
     }

   public void setLocalDate(LocalDate date) {
         this.localDate = date;
     }
}

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.4.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content