quarkus: can't inject @RequestScoped bean in ResteasyReactiveClientResponseFilter - javax.enterprise.context.ContextNotActiveException

Describe the bug

On Quarkus resteasy reactive with a reactive rest client to make an external HTTP call.

It seems that the requestContext is not active when using a ResteasyReactiveClientResponseFilter

I made a simple project to reproduce this issue :
https://github.com/npoirey/quarkus_bugreport_reactiveclientfilter

Injecting a RequestScopedBeam works on a ResteasyReactiveClientRequestFilter but fails on a ResteasyReactiveClientResponseFilter

A similar bug was reported and fixed for the non reactive quarkus http client : https://github.com/quarkusio/quarkus/issues/8538 but this doesn’t work on the reactive version

Expected behavior

my 2 filters should work and print in console

MyRequestFilter
1
MyResponseFilter
1

Actual behavior

injecting the bean works in the request filter but fail with stacktrace on the response filter:

MyRequestFilter
1
MyResponseFilter
2022-08-18 10:58:51,006 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-0) HTTP Request to /hello failed, error id: b683fec2-0839-4c3b-92dc-bbfb8c314c87-1: javax.enterprise.context.ContextNotActiveException: RequestScoped context was not active when trying to obtain a bean instance for a client proxy of CLASS bean [class=org.acme.MyRequestScopedBean, id=4c0d454954d7fcba5081c8479a45d86d4c28035e]
	- you can activate the request context for a specific method using the @ActivateRequestContext interceptor binding
	at io.quarkus.arc.impl.ClientProxies.getDelegate(ClientProxies.java:53)
	at org.acme.MyRequestScopedBean_ClientProxy.arc$delegate(Unknown Source)
	at org.acme.MyRequestScopedBean_ClientProxy.getCounter(Unknown Source)
	at org.acme.MyResponseFilter.filter(MyResponseFilter.java:18)
	at org.acme.MyResponseFilter_Subclass.filter$$superforward1(Unknown Source)
	at org.acme.MyResponseFilter_Subclass$$function$$4.apply(Unknown Source)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:53)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:51)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:40)
	at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
	at org.acme.MyResponseFilter_Subclass.filter(Unknown Source)
	at org.jboss.resteasy.reactive.client.spi.ResteasyReactiveClientResponseFilter.filter(ResteasyReactiveClientResponseFilter.java:10)
	at org.acme.MyResponseFilter_Subclass.filter$$superforward1(Unknown Source)
	at org.acme.MyResponseFilter_Subclass$$function$$3.apply(Unknown Source)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:53)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:51)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:40)
	at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
	at org.acme.MyResponseFilter_Subclass.filter(Unknown Source)
	at org.jboss.resteasy.reactive.client.handlers.ClientResponseFilterRestHandler.handle(ClientResponseFilterRestHandler.java:20)
	at org.jboss.resteasy.reactive.client.handlers.ClientResponseFilterRestHandler.handle(ClientResponseFilterRestHandler.java:9)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.invokeHandler(AbstractResteasyReactiveContext.java:218)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:140)
	at org.jboss.resteasy.reactive.client.impl.RestClientRequestContext$1.lambda$execute$0(RestClientRequestContext.java:276)
	at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:264)
	at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:246)
	at io.vertx.core.impl.EventLoopContext.lambda$runOnContext$0(EventLoopContext.java:43)
	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)

How to Reproduce?

start the example project at https://github.com/npoirey/quarkus_bugreport_reactiveclientfilter

navigate to localhost:8080/hello

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.11.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: C:\Users\npoirey.m2\wrapper\dists\apache-maven-3.8.6-bin\67568434\apache-maven-3.8.6 Java version: 11.0.15, vendor: Eclipse Adoptium, runtime: C:\sources\products\OpenJDK11U_11.0.15_10 Default locale: en_US, platform encoding: Cp1252 OS name: “windows 10”, version: “10.0”, arch: “amd64”, family: “windows”

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 22 (21 by maintainers)

Most upvoted comments

I think you actually might be correct… It doesn’t look like we automatically reactivate it… That’s very weird, I’ll have another look tomorrow.