0

I am using Quarkus, but it has been obtained the following error: "com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Joda date/time type org.joda.time.DateTime not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-joda" to enable handling"

Then, I added the dependency in the pom.xml file:

  <groupId>com.fasterxml.jackson.datatype</groupId>
  <artifactId>jackson-datatype-joda</artifactId>
  <version>2.11.4</version>

But, the error does not disappear. In the resource, I tried to obtain the following request:

@GET
public DateTime getTime(){
    return new DateTime(2019, 03, 24, 3,50);
}

Do you have any suggestions? Thanks

Andres TM
  • 49
  • 4
  • By the way, the Joda-Time project is now in maintenance mode. Its creator Stephen Colebourne went on to lead JSR 310 defining the *java.time* classes built into Java 8 and later. See [this Questiin](https://stackoverflow.com/q/21384820/642706) about Jackson supporting *java.time*. – Basil Bourque May 30 '21 at 07:34

1 Answers1

1

You need to add something like:

@Singleton
public class MyCustomizer implements ObjectMapperCustomizer {

    public void customize(ObjectMapper mapper) {
        mapper.registerModule(new JodaModule());
    }
}

in order to make the ObjectMapper configured by Quarkus, aware of Joda types

geoand
  • 60,071
  • 24
  • 172
  • 190