question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ZonedDateTime can't be deserialized

See original GitHub issue

I’m using spring boot 2.2.5 and I tried to deserialized ZonedDateTime provided by AWS SQS and got the same exception.

the date format I got from amazon as 2020-03-23T09:21:00.353Z

and the exception Could not read JSON: Cannot construct instance of `java.time.ZonedDateTime` (no Creators, like default construct, exist): no String-argument constructor/factory method to deserialize from String value ('2020-03-23T09:21:00.353Z')

I explicitly make jackson as 2.9

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mabujabercommented, Mar 25, 2020

I can narrow it more, I’m using the default ObjectMapper. I tried to customized and register JavaTimeModule but no difference. I can point that I’m using spring-coud-aws for this purpose to consume the message in SQS queue I’m not sure whether spring using a different way of deserializers for this module.

regarding the version jackson I reverted to 2.10 and still the same issue

I raise to spring-cloud-aws team and let see their response.

Thanks

1reaction
kupcicommented, Mar 25, 2020

Ok, that helps narrow it, I suppose this issue can be closed? (Not sure what I was thinking on the array unwrapping, I see in the example that it is not an array.)

Though it would still be interesting to know why it doesn’t work out of the box for Spring Boot. Maybe a config issue with the way Spring is registering the Java time module? One possibility - are you using your own mapper or the default mapper?

If you are using the default ObjectMapper the handling of Java 8 date is picked up automatically by Spring Boot. However, if you have defined your own ObjectMapper you might need to register the module.

https://codeboje.de/jackson-java-8-datetime-handling/

Now, a bit more about the registration - mabujaber mentioned explicitly using 2.9, and I see from the documentation the following:

Also note that before Jackson 2.10, auto-registration will only register older JSR310Module, and not newer JavaTimeModule – this is due to backwards compatibility. This is changed in Jackson 2.10.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jackson deserialization issue for ZonedDateTime
Jackson deserialize will by default to by pass the timezone infor and ... JsonMappingException: Can not instantiate value of type [simple ...
Read more >
Option to have ZonedDateTime perform lenient deserialization
We are currently using the DataContractSerializer for serializing ZonedDatime data (among a lot of other things) to disk. We are in the process...
Read more >
Value class NodaTime.ZonedDateTime cannot be ...
Coding example for the question NodaTime with MongoDB: Value class NodaTime.ZonedDateTime cannot be deserialized-mongodb.
Read more >
Jackson Date - Baeldung
Deserialize Joda ZonedDateTime With Time Zone Preserved ... InvalidDefinitionException: Cannot construct instance of `java.time.
Read more >
Simple Jackson Deserializer - pieterjd.be
As I was working on some random data with a ZonedDateTime, it turned out Jackson was unable to deserialize it. How come?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found