Search code examples
jodatimequarkus

Joda time in Quarkus


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


Solution

  • 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