Quarkus: Jackson deserialization not supported for REST client without including RESTEasy server

Created on 22 Mar 2020  路  9Comments  路  Source: quarkusio/quarkus

Describe the bug
Jackson JSON deserialization is not supported with Quarkus REST client without including dependencies for the RESTEasy server.

Expected behavior
One should be able to use the Quarkus REST client with Jackson, independent from the server.
The following dependencies should be sufficient to support Jackson JSON deserialization on the REST client:

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-jackson</artifactId>
</dependency>

Actual behavior
Running with just these 2 dependencies produces the following error:

WARN  [io.qua.res.com.dep.ResteasyCommonProcessor] (build-11) Quarkus detected the need of REST JSON support but you have not provided the necessary JSON extension for this. You can visit https://quarkus.io/guides/rest-json for more information on how to set one.
...
ERROR [...] ProcessingException while creating reply for journey details request: RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json and type class X.

The deserialization issue is solved when adding the quarkus-resteasy-jackson dependency. However this also starts the web server, which might not always be desired and adds some unused overhead.

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>

In my (basic) test case, the issue could be solved by adding an additional dependency. But this might not be an appropriate solution (or might not work in all cases - especially in native image).

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-jackson</artifactId>
</dependency>
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jackson2-provider</artifactId>
</dependency>

Environment:

  • Quarkus 1.3.0.Final
  • Maven 3.6.3 with option -Dquarkus.native.container-build=true

Additional context
Original question on StackOverflow: https://stackoverflow.com/q/60787746/12355118

kinenhancement

Most helpful comment

@PieterjanDeconinck in 1.4, you will have the rest-client-jackson, rest-client-jsonb and rest-client-jaxb extensions.

This should solve your issue!

All 9 comments

As you have already found, the combination of:

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-jackson</artifactId>
</dependency>
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jackson2-provider</artifactId>
</dependency>

will give you the necessary result.

And it does work in native as well (I also verified this in an example project), @PieterjanDeconinck @kenfinnigan (I saw you commented on the SO answer) why do you think it doesn't?.
From an implementation perspective the code that registers providers is common to both the client and the server. Furthermore the quarkus-resteasy-jackson module doesn't do anything that the client needs.

So I will close this issue unless you have a reproducer project that demonstrates an issue with native.

Thanks!

@geoand is it user-friendly enough though? I mean the rest-client extension doesn't really say anything about RESTEasy.

I wonder if we should create some simple extensions to handle that for the rest-client e.g. rest-client-jackson, rest-client-jsonb and rest-client-jaxb. They wouldn't be any different from the one we have for the server.

@gsmet sure, we could do that, I don't see why not

I will reopen this issue. It's not the first time we had people complaining about that, that's why I think it's worth doing something.

I need some easy tasks for this morning, I'll go do that.

@gsmet OK, sounds good :)

Feel free to request a review from me @gsmet when you have things all set up

@PieterjanDeconinck in 1.4, you will have the rest-client-jackson, rest-client-jsonb and rest-client-jaxb extensions.

This should solve your issue!

Very nice, thx!

PR https://github.com/quarkusio/quarkus/pull/8089 was merged.

We can close this issue.

Was this page helpful?
0 / 5 - 0 ratings