1

I'm using Quarkus 2.8.2. So far I have been using the quarkus-resteasy dependencies in my project. The release notes for 2.8 tell me I should switch to quarkus-resteasy-reactive and it's a 1:1 replacment and no changes are necessary. However, after doing that my unit tests won't work any more due to

17:13:55.117 [executor-thread-0] ERROR io.quarkus.vertx.http.runtime.QuarkusErrorHandler - HTTP Request to /accounts failed, error id: 3cdf0e30-713d-4f0f-aed4-624d34a8c074-1
org.jboss.resteasy.spi.LoggableFailure: RESTEASY003880: Unable to find contextual data of type: javax.ws.rs.core.UriInfo
    at org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:155) ~[resteasy-core-4.7.5.Final.jar:4.7.5.Final]
    at jdk.proxy4.$Proxy121.getBaseUri(Unknown Source) ~[?:?]
    at xxx.Util.getRootUri(Util.java:282) ~[utility-2.0.0-LOCAL.jar:?]
    at xxx.Util.getBaseUri(Util.java:256) ~[utility-2.0.0-LOCAL.jar:?]
    at xxx.providers.ASGenericJSONSerializer.getWriterAttributes(ASGenericJSONSerializer.java:58) ~[quarkus:/:?]
    at xxx.providers.json.GenericJSONSerializer.writeToStream(GenericJSONSerializer.java:132) ~[quarkus:/:?]
    at xxx.providers.json.GenericJSONSerializer.writeTo(GenericJSONSerializer.java:116) ~[quarkus:/:?]
    at org.jboss.resteasy.reactive.server.core.ServerSerialisers.invokeWriter(ServerSerialisers.java:220) ~[resteasy-reactive-2.8.2.Final.jar:2.8.2.Final]
    at org.jboss.resteasy.reactive.server.core.ServerSerialisers.invokeWriter(ServerSerialisers.java:178) ~[resteasy-reactive-2.8.2.Final.jar:2.8.2.Final]
    at org.jboss.resteasy.reactive.server.core.serialization.DynamicEntityWriter.write(DynamicEntityWriter.java:102) ~[resteasy-reactive-2.8.2.Final.jar:2.8.2.Final]
    at org.jboss.resteasy.reactive.server.handlers.ResponseWriterHandler.handle(ResponseWriterHandler.java:31) ~[resteasy-reactive-2.8.2.Final.jar:2.8.2.Final]
    at org.jboss.resteasy.reactive.server.handlers.ResponseWriterHandler.handle(ResponseWriterHandler.java:15) ~[resteasy-reactive-2.8.2.Final.jar:2.8.2.Final]
    at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:141) [resteasy-reactive-common-2.8.2.Final.jar:2.8.2.Final]
    at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:548) [quarkus-vertx-2.8.2.Final.jar:2.8.2.Final]
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449) [jboss-threads-3.4.2.Final.jar:3.4.2.Final]
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478) [jboss-threads-3.4.2.Final.jar:3.4.2.Final]
    at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29) [jboss-threads-3.4.2.Final.jar:3.4.2.Final]
    at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29) [jboss-threads-3.4.2.Final.jar:3.4.2.Final]
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.74.Final.jar:4.1.74.Final]
    at java.lang.Thread.run(Thread.java:833) [?:?]

The culprit is

    @Context
    private UriInfo m_uriInfo;

in a JAX-RS @Provider (a MessageBodyWriter). The variable contains a proxy object but when I try to access the base URI the above exception is thrown. Note that I'm not using any of the reactive functionality explicitly.

Any hints where the problem is? Looks like a bug to me since it has worked before.

sithmein
  • 437
  • 3
  • 11
  • If I understand correctly, RESTEasy Reactive handles dependency injection somewhat differently (unifying on CDI instead of the JAX-RS dependency injection facility). Could you try replacing that `@Context` with `@Inject`? I'm no RESTEasy Reactive expert (and I understand this might not be what you want to hear), but that _might_ help. – Ladicek Apr 28 '22 at 15:38
  • Do you have a sample somewhere I can look at? The `@Context` should work... – geoand Apr 28 '22 at 17:40
  • I exchanged `@Context` with `@Inject` and now it works. This is a solution but this indicates even more that this is a bug. In a JAX-RS provider you are supposed to use `@Context` and not `@Inject`. – sithmein Apr 28 '22 at 18:03
  • Please open an issue so we can address this bug – geoand Apr 29 '22 at 09:00
  • I spent several hours trying to come up with a minimal reproducer and eventually found the root cause. It was a mixture of reactive and non-reactive RESTEasy used in the same project. The non-reactive library was pulled in via a longer dependency chain. Is there any way Quarkus could warn or even error out if such an incompatible mixture exists? – sithmein Apr 29 '22 at 13:11
  • That is a very good point. We actually do prevent `quarkus-resteasy` and `quarkus-resteasy-reactive` from being used together. But we don't warn about non-Quarkus RESTEasy dependencies. What dependency was on the classpath and how did it get there? – geoand May 03 '22 at 11:15
  • Unfortunately I cannot reproduce it any more since we did quite some changes since then and now I indeed get an error during boot if conflicting dependencies are present. – sithmein May 10 '22 at 07:25

0 Answers0