Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joda DateTime serialization fails when Accept header is set to application/xml #38965

Closed
puthukkots opened this issue Jan 3, 2024 · 4 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@puthukkots
Copy link

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

@puthukkots puthukkots reopened this Jan 3, 2024
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 3, 2024
@bclozel
Copy link
Member

bclozel commented Jan 3, 2024

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

@bclozel bclozel added the status: waiting-for-feedback We need additional information before we can continue label Jan 3, 2024
@puthukkots
Copy link
Author

@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

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 4, 2024
@wilkinsona
Copy link
Member

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.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Jan 4, 2024
@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Jan 4, 2024
@prashil-g
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

5 participants