RequestScoped context was not active when trying to obtain a bean instance for a client proxy of PRODUCER_METHOD ....D bean · Issue #893 · a2aproject/a2a-java · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RequestScoped context was not active when trying to obtain a bean instance for a client proxy of PRODUCER_METHOD ....D bean #893
An A2A Agent Server Executor producer class is throwing this error when calling a Rest Client
jakarta.enterprise.context.ContextNotActiveException: RequestScoped context was not active when trying to obtain a bean instance for a client proxy of PRODUCER_METHOD bean [class=io.quarkus.oidc.runtime.OidcTokenCredentialProducer, id=qPtfJ2z9Vcs78nLYoSxmBSZ461Y]
- you can activate the request context for a specific method using the @ActivateRequestContext interceptor binding
at io.quarkus.arc.impl.ClientProxies.notActive(ClientProxies.java:76)
at io.quarkus.arc.impl.ClientProxies.getSingleContextDelegate(ClientProxies.java:32)
at io.quarkus.oidc.OidcTokenCredentialProducer_ProducerMethod_currentAccessToken_LqZ323vwEzgoIJymPKn-DMYcc6w_ClientProxy.arc$delegate(Unknown Source)
at io.quarkus.oidc.OidcTokenCredentialProducer_ProducerMethod_currentAccessToken_LqZ323vwEzgoIJymPKn-DMYcc6w_ClientProxy.getToken(Unknown Source)
at org.acme.WanakuAgentExecutorProducer$WanakuAgentExecutor.execute(WanakuAgentExecutorProducer.java:93)
at org.a2aproject.sdk.server.requesthandlers.DefaultRequestHandler$2.run(DefaultRequestHandler.java:935)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
at io.smallrye.context.impl.wrappers.SlowContextualRunnable.run(SlowContextualRunnable.java:19)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$15.runWith(VertxCoreRecorder.java:677)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2651)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2630)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1622)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1589)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:1583)
2026-05-23 15:19:41,661 ERROR [org.a2aproject.sdk.server.requesthandlers.DefaultRequestHandler] (a2a-event-consumer-1) onError for task 1e4f3f4f-7d5f-4c07-a09d-c86a093e0da4: org.a2aproject.sdk.spec.InternalError: Agent execution failed: RequestScoped context was not active when trying to obtain a bean instance for a client proxy of PRODUCER_METHOD bean [class=io.quarkus.oidc.runtime.OidcTokenCredentialProducer, id=qPtfJ2z9Vcs78nLYoSxmBSZ461Y]
- you can activate the request context for a specific method using the @ActivateRequestContext interceptor binding
at org.a2aproject.sdk.server.requesthandlers.DefaultRequestHandler$2.run(DefaultRequestHandler.java:946)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
at io.smallrye.context.impl.wrappers.SlowContextualRunnable.run(SlowContextualRunnable.java:19)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$15.runWith(VertxCoreRecorder.java:677)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2651)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2630)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1622)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1589)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:1583)
it's rather straightforward setup. Even i got the rest client setup to call a public, not protected hello world endpoint like this in the application.properties, still throwing the same error.
I didn't try using Quarkus Mutiny on the Rest Client to return a Uni and make the rest call none blocking. i don't think it'd make any difference in terms of this error.
AgentExecutor >> AI Service >> Tools exposing the rest API
AgentExecutor >> AI Service >> MCP >> run the tool that exposes the rest API
Since i have to propagate the access token available from the A2A Server Agent request context, i much rather call the Rest API directly from the AgentExecutor to keep things simple
the token propagation when quarkus-langchain4j-oidc-mcp-auth-provider quarkus is extension added to the quarkus app seems to have stopped working in 1.0.0.CR1.
not sure it's related to the same underlying issue or a separate one. I can raise a ticket for it if need be but essentially in the scenario where an A2A client Agent calls a A2A Server agent protected by oidc scheme which in turns runs a AI Service to call a tool exposed by an MCP that is also protected by OIDC, the JWT token acquired by the A2A client Agent used to authenticate the request to the A2A server agent get propagated successfully during the MCP call (Authorization header gets set to the same JWT access token) only when the pom file is set with <version>1.0.0.Beta1</version>
if switched to <version>1.0.0.CR1</version> , the MCP calls fails returning 401 error code.
@ehsavoie , i didn't try. i never enabled OpenTelemetry in any of my Quarkus app. let me give it a go, it might take me a while to get this test done. hopefully at some point today
: jakarta.enterprise.context.ContextNotActiveException: RequestScoped context was not active when trying to obtain a bean instance for a client proxy of PRODUCER_METHOD bean [class=io.quarkus.oidc.runtime.OidcTokenCredentialProducer, id=qPtfJ2z9Vcs78nLYoSxmBSZ461Y]
- you can activate the request context for a specific method using the @ActivateRequestContext interceptor binding
at io.quarkus.arc.impl.ClientProxies.notActive(ClientProxies.java:76)
at io.quarkus.arc.impl.ClientProxies.getSingleContextDelegate(ClientProxies.java:32)
at io.quarkus.oidc.OidcTokenCredentialProducer_ProducerMethod_currentAccessToken_LqZ323vwEzgoIJymPKn-DMYcc6w_ClientProxy.arc$delegate(Unknown Source)
at io.quarkus.oidc.OidcTokenCredentialProducer_ProducerMethod_currentAccessToken_LqZ323vwEzgoIJymPKn-DMYcc6w_ClientProxy.getToken(Unknown Source)
at io.quarkus.oidc.token.propagation.reactive.AccessTokenRequestReactiveFilter.verifyTokenInstance(AccessTokenRequestReactiveFilter.java:158)
at io.quarkus.oidc.token.propagation.reactive.AccessTokenRequestReactiveFilter.filter(AccessTokenRequestReactiveFilter.java:87)
at org.jboss.resteasy.reactive.client.spi.ResteasyReactiveClientRequestFilter.filter(ResteasyReactiveClientRequestFilter.java:21)
at org.jboss.resteasy.reactive.client.handlers.ClientRequestFilterRestHandler.handle(ClientRequestFilterRestHandler.java:25)
at org.jboss.resteasy.reactive.client.handlers.ClientRequestFilterRestHandler.handle(ClientRequestFilterRestHandler.java:10)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.invokeHandler(AbstractResteasyReactiveContext.java:231)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
at org.jboss.resteasy.reactive.client.impl.AsyncInvokerImpl.performRequestInternal(AsyncInvokerImpl.java:285)
at org.jboss.resteasy.reactive.client.impl.AsyncInvokerImpl.performRequestInternal(AsyncInvokerImpl.java:275)
at org.jboss.resteasy.reactive.client.impl.AsyncInvokerImpl.method(AsyncInvokerImpl.java:235)
at org.jboss.resteasy.reactive.client.impl.InvocationBuilderImpl.method(InvocationBuilderImpl.java:328)
at org.acme.BinanceLocalAgentRestClient$$QuarkusRestClientInterface.callBinanceLocalAgent(Unknown Source)
at org.acme.BinanceLocalAgentRestClient$$CDIWrapper.callBinanceLocalAgent(Unknown Source)
at org.acme.BinanceLocalAgentRestClient$$CDIWrapper_ClientProxy.callBinanceLocalAgent(Unknown Source)
at org.acme.WanakuAgentExecutorProducer$WanakuAgentExecutor.execute(WanakuAgentExecutorProducer.java:92)
at org.a2aproject.sdk.server.requesthandlers.DefaultRequestHandler$2.run(DefaultRequestHandler.java:935)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
at io.smallrye.context.impl.wrappers.SlowContextualRunnable.run(SlowContextualRunnable.java:19)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$15.runWith(VertxCoreRecorder.java:677)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2651)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2630)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1622)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1589)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:1583)
on the above configuration i just made one change 1.0.0.Beta1, run the same test, all works perfect.
this is the AsyncManagedExecutorProducer class added to my A2A Server quarkus app. This is the version from the last pull request committed by @kabir this week.
package org.acme;
import java.util.concurrent.Executor;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Priority;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Alternative;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;
import org.a2aproject.sdk.server.util.async.Internal;
import org.eclipse.microprofile.context.ManagedExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Alternative executor producer that provides a ManagedExecutor with CDI context propagation.
* <p>
* This producer replaces the default {@code AsyncExecutorProducer} so that CDI request context
* (and any other registered thread context types) are propagated to the agent executor thread.
* This allows {@code @RequestScoped} beans to be injected and used inside
* {@link org.a2aproject.sdk.server.agentexecution.AgentExecutor#execute}.
* <p>
* Priority 20 ensures this alternative takes precedence over the default producer (priority 10).
*
* @see org.eclipse.microprofile.context.ManagedExecutor
*/
@ApplicationScoped
@Alternative
@Priority(20)
public class AsyncManagedExecutorProducer {
private static final Logger LOGGER = LoggerFactory.getLogger(AsyncManagedExecutorProducer.class);
@Inject
ManagedExecutor managedExecutor;
@PostConstruct
public void init() {
LOGGER.info("Initializing ManagedExecutor for async operations with CDI context propagation");
if (managedExecutor == null) {
LOGGER.warn("ManagedExecutor not available - context propagation may not work correctly");
}
}
@Produces
@Internal
public Executor produce() {
LOGGER.debug("Using ManagedExecutor for async operations with CDI context propagation");
if (managedExecutor == null) {
throw new IllegalStateException("ManagedExecutor not injected - ensure MicroProfile Context Propagation is available");
}
return managedExecutor;
}
}
thanks @kabir, i will try put together a reproducer that spins up a keycloak instance using quarkus devservices and a protected Rest resource to echo Hello World!, all running locally. I need sometime to do this, hopefully i'll be ready today
thanks @ehsavoie, yes, the link you provided is for the extension i am using to propagate the Bearer token from the AgentExecutor to the Rest client. The A2A client acquire an access token (issued by keycloak) which is used to authenticate the request against the A2A Server agent (exposing an AgentCard proteced with OIDC scheme), that same token get propagated downstream using quarkus-rest-client-oidc-token-propagation quarkus extension which gets triggered when rest client is annotated with @accesstoken (as show in some of the code snipped provided earlier)
I also added a thing to bypass the LLM from the agent executor, so start the server with mvn quarkus:dev -Dskip.agent=true.
It takes a while before the server is ready, even after I am able to get the agent card in my browser. But eventually the example passes with all three versions.
I have the reproducer ready. it consists of 3 quarkus apps (couldn't make it simpler than that). Unzip the 3 files to a local folder for instance /home/admin/A2A.
step 1: start up keycloak
cd /home/admin/A2A/keycloak-reproducer
./mvnw quarkus:dev
this start up Keycloak on port 9001. You need to wait till Keycloak is fully up and running otherwise the other 2 apps won't start up due to the OIDC extension dependency on the Idp being available.
step 2: start up A2A Server Agent
cd /home/admin/A2A/a2a-server-agent-reproducer
./mvnw quarkus:dev
this start up the A2A Server agent on port 8001
step 3: start up A2A Client Agent
cd /home/admin/A2A/a2a-client-agent-reproducer
./mvnw quarkus:dev
this start up the A2A Client agent on port 7001
step 4: test
go to http://localhost:7001/keycloak/hello
browser should be redirected to keycloak login page
log on as bob/bob or alice/alice
the page should render "Hello from Quarkus REST - A2A Client Agent: Hello from A2A Server Agent: Miguel"
Step 5: reproduce the issue
edit the pom.xml file under the a2a-server-agent-reproducer quarkus app
reset version to 1.0.0.CR1
Save and retest
go to http://localhost:7001/keycloak/hello
log on as bob/bob or alice/alice
this error comes back
org.a2aproject.sdk.spec.InternalError: Agent execution failed: RequestScoped context was not active when trying to obtain a bean instance for a client proxy of PRODUCER_METHOD bean [class=io.quarkus.oidc.runtime.OidcTokenCredentialProducer, id=qPtfJ2z9Vcs78nLYoSxmBSZ461Y]
- you can activate the request context for a specific method using the @ActivateRequestContext interceptor binding
at org.a2aproject.sdk.server.requesthandlers.DefaultRequestHandler$2.run(DefaultRequestHandler.java:946)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
at io.smallrye.context.impl.wrappers.SlowContextualRunnable.run(SlowContextualRunnable.java:19)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$15.runWith(VertxCoreRecorder.java:677)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2651)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2630)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1622)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1589)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:1583)
I also added a thing to bypass the LLM from the agent executor, so start the server with mvn quarkus:dev -Dskip.agent=true.
It takes a while before the server is ready, even after I am able to get the agent card in my browser. But eventually the example passes with all three versions.
Thanks @kabir, i remember those examples. mostly taking artifacts form the platform i am building right now stripping things out as much as i could. Let me know if you're able to run through the reproducer fine.
Activity
mescaja commentedon May 23, 2026
i tried annotate the Rest client class with @ActivateRequestContext, no difference whatsoever
mescaja commentedon May 23, 2026
these are other alternatives
Since i have to propagate the access token available from the A2A Server Agent request context, i much rather call the Rest API directly from the AgentExecutor to keep things simple
mescaja commentedon May 23, 2026
i am using JSONRPC transport from 1.0.0.CR1 SDK with Quarkus 3.35.4
kabir commentedon May 26, 2026
Thanks for the report, I'm trying to fix it
mescaja commentedon May 26, 2026
thanks @kabir
the token propagation when quarkus-langchain4j-oidc-mcp-auth-provider quarkus is extension added to the quarkus app seems to have stopped working in 1.0.0.CR1.
not sure it's related to the same underlying issue or a separate one. I can raise a ticket for it if need be but essentially in the scenario where an A2A client Agent calls a A2A Server agent protected by oidc scheme which in turns runs a AI Service to call a tool exposed by an MCP that is also protected by OIDC, the JWT token acquired by the A2A client Agent used to authenticate the request to the A2A server agent get propagated successfully during the MCP call (Authorization header gets set to the same JWT access token) only when the pom file is set with
<version>1.0.0.Beta1</version>if switched to
<version>1.0.0.CR1</version>, the MCP calls fails returning 401 error code.kabir commentedon May 26, 2026
@mescaja Does the linked PR #897 fix the problem?
mescaja commentedon May 26, 2026
let me give it a go today. will confirm
fix: Propagate CDI context to AgentExecutor thread (#897)
mescaja commentedon May 26, 2026
i don't think it's fixed although i may have not implemented the fix in my environment correctly. I will check it again tomorrow
Still getting the 401 error which goes away if i downgrade from CR1 to Beta1
ehsavoie commentedon May 27, 2026
@mescaja Does it work if you enable opentelemetry in CR1 ?
mescaja commentedon May 27, 2026
@ehsavoie , i didn't try. i never enabled OpenTelemetry in any of my Quarkus app. let me give it a go, it might take me a while to get this test done. hopefully at some point today
mescaja commentedon May 27, 2026
i might need some guidance here. Not sure all is correctly setup in terms of enabling OTel
I added a few dependencies to my pom in the A2A server agent
run a test, same issue
on the above configuration i just made one change 1.0.0.Beta1, run the same test, all works perfect.
mescaja commentedon May 27, 2026
this is the AsyncManagedExecutorProducer class added to my A2A Server quarkus app. This is the version from the last pull request committed by @kabir this week.
6 remaining items
kabir commentedon May 28, 2026
Let's reopen this while we work it out.
@mescaja Would you be able to provide a small reproducer?
ehsavoie commentedon May 28, 2026
@mescaja that means that there is a token that is found if I read the code in https://github.com/quarkusio/quarkus/blob/main/extensions/oidc-token-propagation-reactive/runtime/src/main/java/io/quarkus/oidc/token/propagation/reactive/AccessTokenRequestReactiveFilter.java correctly
mescaja commentedon May 28, 2026
thanks @kabir, i will try put together a reproducer that spins up a keycloak instance using quarkus devservices and a protected Rest resource to echo Hello World!, all running locally. I need sometime to do this, hopefully i'll be ready today
thanks @ehsavoie, yes, the link you provided is for the extension i am using to propagate the Bearer token from the AgentExecutor to the Rest client. The A2A client acquire an access token (issued by keycloak) which is used to authenticate the request against the A2A Server agent (exposing an AgentCard proteced with OIDC scheme), that same token get propagated downstream using quarkus-rest-client-oidc-token-propagation quarkus extension which gets triggered when rest client is annotated with @accesstoken (as show in some of the code snipped provided earlier)
kabir commentedon May 28, 2026
Hi @mescaja,
We realized we have a sample we did for 0.3, which uses Keycloak etc. Maybe this can be a good basis for your reproducer.
Take a look at https://github.com/kabir/a2a-samples/compare/token-investigation?expand=1. I have updated the Magic 8 Ball sample to use 1.0.0.Beta1 and 1.0.0.CR1 (separate commits).
I also added a thing to bypass the LLM from the agent executor, so start the server with
mvn quarkus:dev -Dskip.agent=true.It takes a while before the server is ready, even after I am able to get the agent card in my browser. But eventually the example passes with all three versions.
mescaja commentedon May 28, 2026
I have the reproducer ready. it consists of 3 quarkus apps (couldn't make it simpler than that). Unzip the 3 files to a local folder for instance /home/admin/A2A.
step 1: start up keycloak
this start up Keycloak on port 9001. You need to wait till Keycloak is fully up and running otherwise the other 2 apps won't start up due to the OIDC extension dependency on the Idp being available.
step 2: start up A2A Server Agent
this start up the A2A Server agent on port 8001
step 3: start up A2A Client Agent
this start up the A2A Client agent on port 7001
step 4: test
go to http://localhost:7001/keycloak/hello
browser should be redirected to keycloak login page
log on as bob/bob or alice/alice
the page should render "Hello from Quarkus REST - A2A Client Agent: Hello from A2A Server Agent: Miguel"
Step 5: reproduce the issue
edit the pom.xml file under the a2a-server-agent-reproducer quarkus app
reset version to 1.0.0.CR1
Save and retest
go to http://localhost:7001/keycloak/hello
log on as bob/bob or alice/alice
this error comes back
i will upload the 3 quarkus apps now
mescaja commentedon May 28, 2026
having issue uploading the zip file
mescaja commentedon May 28, 2026
keycloak-reproducer.zip
mescaja commentedon May 28, 2026
a2a-client-agent-reproducer.zip
mescaja commentedon May 28, 2026
a2a-server-agent-reproducer.zip
mescaja commentedon May 28, 2026
Thanks @kabir, i remember those examples. mostly taking artifacts form the platform i am building right now stripping things out as much as i could. Let me know if you're able to run through the reproducer fine.
kabir commentedon May 29, 2026
@mescaja It's taken some digging but I might have a fix!
It passes for me with #902.
There are a few things I'm not convinced about, so I'll check a few things in a fresh Claude session on Monday ;-)
mescaja commentedon May 31, 2026
Thanks a lot @kabir sounds like you're nearly there. i'll run a test as soon as you tell me it's all ready to go
kabir commentedon Jun 1, 2026
@mescaja I think I have fixed it properly now, see #904