Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestScope not active when using Fault Tolerance #3810

Closed
gmpatter opened this issue Jan 14, 2022 · 2 comments
Closed

RequestScope not active when using Fault Tolerance #3810

gmpatter opened this issue Jan 14, 2022 · 2 comments
Assignees
Milestone

Comments

@gmpatter
Copy link

Environment Details

  • Helidon Version: 2.4.1
  • Helidon MP
  • JDK version: 11.0.9
  • OS: MacOS

Problem Description

"No active contexts for scope type javax.enterprise.context.RequestScoped" seen when using Fault Tolerance annotations and Request Scope in Helidon MP application.

Full stack trace:

2022.01.14 20:25:01 WARNING io.helidon.microprofile.server.JaxRsCdiExtension Thread[helidon-1,5,server]: Internal server error
org.jboss.weld.contexts.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped
	at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:647)
	at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:89)
	at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:164)
	at org.jboss.weld.bean.ContextualInstance.getIfExists(ContextualInstance.java:63)
	at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:87)
	at org.jboss.weld.bean.proxy.ProxyMethodHandler.getInstance(ProxyMethodHandler.java:131)
	at io.helidon.examples.quickstart.mp.ResponseWriterInterceptor$Proxy$_$$_WeldClientProxy.aroundWriteTo(Unknown Source)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
	at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:85)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
	at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:61)
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
	at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1116)
	at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:635)
	at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:373)
	at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:363)
	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:258)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684)
	at io.helidon.webserver.jersey.JerseySupport$JerseyHandler.lambda$doAccept$4(JerseySupport.java:326)
	at io.helidon.common.context.Contexts.runInContext(Contexts.java:117)
	at io.helidon.common.context.ContextAwareExecutorImpl.lambda$wrap$7(ContextAwareExecutorImpl.java:154)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

Steps to reproduce

Create a JAXRS Application:

@ApplicationScoped
@ApplicationPath("/")
public class TestApplication extends Application {

  @Override
  public Set<Class<?>> getClasses() {
    return Set.of(TestResource.class, ResponseWriterInterceptor.class);
  }

}

Create a Resource class with Fault Tolerance annotation on an endpoint:

@Path("/test")
public class TestResource {

  @Timeout
  @GET
  public String getTenantResource() throws Exception {
    return "some string";
  }
}

WriterInterceptor:

@Provider
@RequestScoped
public class ResponseWriterInterceptor implements WriterInterceptor {

  @Override
  public void aroundWriteTo(WriterInterceptorContext writerInterceptorContext) {
    System.out.println("some string");
  }
}

Hit endpoint, observe error when WriterInterceptor is invoked.
If we remove the @timeout annotation we don't see the error.

We actually see the error in our service code called by the endpoint in our app, and also in a request scoped writer interceptor during the same request. I wasn't able to recreate the issue in code called by the endpoint in a simple app, but could get it with the WriterInterceptor setup. So not necessarily tied to use of a request scoped interceptor, but just the simplest app I could recreate with.

@spericas spericas self-assigned this Jan 18, 2022
@spericas spericas added this to the 2.4.2 milestone Jan 18, 2022
@spericas
Copy link
Member

@gmpatter I'm able to reproduce the problem: I see that I need both the FT annotation and the interceptor in request scope. Without one of those, I don't see the error. Will investigate.

@spericas
Copy link
Member

PR #3825
PR #3813

@m0mus m0mus added this to Backlog Aug 12, 2024
@m0mus m0mus moved this to Closed in Backlog Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants