quarkus: Java 8 DateTime can NOT be unserialized in Vertx Mutiny WebClient
The client sample code is here.
I have added the following dependencies.
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-mutiny</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>smallrye-mutiny-vertx-web-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
I used the post-service as api producer.
When run post-service(:8081/api), restclient-vertx-munity(:8080/posts), and background mongodb(via docker-compose up postgres) respectively.
And access http://localhost:8081/api, and got the following exceptions in the console of restclient-vertx-munity.
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `java.time.LocalDateTime` (no Creators, like default construct, exist): no String-argument constructor/factory method to deserialize from String value ('2020-06-03T18:04:45.125679')
at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: com.example.Post["createdAt"])
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (19 by maintainers)
Workaround for the time being:
I’m not sure I see an easy way out here…
The
ObjectMapperused by Vert.x has some specific customization. The fields inJsonare public static so we could override them as long as we do it early enough. We could have to talk to @vietj about that though.And then, we have two options: either entirely replace the mapper and apply the specific Vert.x extensions as customizers or do the opposite and apply the customizers on top of the Vert.x ones.
All in all, I think a discussion with @vietj is necessary.
In the meantime, I think you could just push your own mapper to
Jsonin a startup event. Not pretty but that should work.