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
This error is encountered even with jackson-datatype-joda dependency added and JodaTime module registered, only when Accept header of the request is application/xml. Looks like this issue is present in springboot versions higher that 2.7.18.
Adding a sample application with test case demo.zip
Comment From: bclozel
Can you replicate this problem with a supported version of Spring Boot? The 2.7.x generation is out of open source support, see https://spring.io/projects/spring-boot/#support
Comment From: puthukkots
@bclozel The attached demo project uses version 3.0.9.Pleae have a look.There is no issue with 2.7.x ,it works there
Comment From: wilkinsona
Spring Framework's support for Joda Time has been deprecated since 5.3 and was removed in 6.0 in favor of the java.time APIs there were introduced in Java 8. This means that Spring Framework 6 does not register Jackson's JodaModule by default. This default registration is required as your tests are using a standalone MockMvc configuration so any beans in the context make no different to the test's configuration. Even if they did, your context contains an ObjectMapper bean and conversion to XML requires an XmlMapper.
To avoid the problem, I would recommend switching from Joda Time to the standard java.time API as part of your Spring Boot 3.x (and Spring Framework 6.x) upgrade.
Comment From: prashil-g
Is there any guidance on how we migrate from Joda time to java time, when dependent upstream service is still expecting payload to have joda time fields?