I need some help understanding how Resteasy messes up my registered Providers
I have 2 services, lets call them Scheduler and Process. Process has a ClientRequestFilter annotated with @Provider that adds some headers to Rest Requests. Scheduler regularly calls an entirely different service via Rest.It does not have a requestfilter, nor any dependency to Process.
Still, sometimes when I start my wildfly27 container that contains these Services, my Scheduler will permanently throw Exceptions, whose stacktraces contain the Filter of my Process. (The filter injects HttpServletRequest, which isn't available there )
Now as far as hours of googling got me, I think that all classes registered as providers are registered to the entire Resteasy runtime within wildfly, not just the specific deployment they're contained in.
Now what I dont understand is why this behaviour appears to be completely random. Sometimes the container and services start just fine, sometimes they have this issue. The order in which they are deployed seems to have no effect on this. Undeploying the process which contains the requestfilter afterwards also does not change anything about this.
Removing the Provider annotation and instead listing the filter in the jakarta.ws.rs.ext.Providers file also had no effect.
It seems that a solution to this would be to manually register all resources and providers in the Application Class of the deployments, but I'm not really that fond of manually adjusting numerous services that run within the same wildfly server and copying every single rest resource there. Manually registering providers to every single rest client is also out of the question for the same reason.
Can anyone clear up my confusion, and maybe even suggest a proper solution? Thanks in advance
stacktrace:
jakarta.ws.rs.ProcessingException: org.jboss.weld.contexts.ContextNotActiveException: WELD-001303: No active contexts for scope type jakarta.enterprise.context.RequestScoped]
wildfly27_1 | at deployment.scheduler.war//.scheduler.jobs.AbstractRestJob.execute(AbstractRestJob.java:61)
wildfly27_1 | at deployment.scheduler.war//org.quartz.core.JobRunShell.run(JobRunShell.java:202)
wildfly27_1 | at deployment.scheduler.war//org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
wildfly27_1 | Caused by: jakarta.ws.rs.ProcessingException: org.jboss.weld.contexts.ContextNotActiveException: WELD-001303: No active contexts for scope type jakarta.enterprise.context.RequestScoped
wildfly27_1 | at [email protected]//org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.filterRequest(ClientInvocation.java:767)
wildfly27_1 | at [email protected]//org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:499)
wildfly27_1 | at [email protected]//org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:71)
wildfly27_1 | at [email protected]//org.jboss.resteasy.client.jaxrs.internal.ClientInvocationBuilder.get(ClientInvocationBuilder.java:198)
wildfly27_1 | at deployment.scheduler.war//scheduler.jobs.RestGetJob.performRequest(RestGetJob.java:16)
wildfly27_1 | at deployment.scheduler.war//scheduler.jobs.AbstractRestJob.execute(AbstractRestJob.java:45)
wildfly27_1 | ... 2 more
wildfly27_1 | Caused by: org.jboss.weld.contexts.ContextNotActiveException: WELD-001303: No active contexts for scope type jakarta.enterprise.context.RequestScoped
wildfly27_1 | at [email protected]//org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:628)
wildfly27_1 | at [email protected]//org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:89)
wildfly27_1 | at [email protected]//org.jboss.weld.bean.ContextualInstance.getIfExists(ContextualInstance.java:63)
wildfly27_1 | at [email protected]//org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:87)
wildfly27_1 | at [email protected]//org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)
wildfly27_1 | at [email protected]//org.jboss.weld.generated.proxies.servlet.http.HttpServletRequest$Proxy$_$$_WeldClientProxy.getRemoteUser(Unknown Source)
wildfly27_1 | at deployment.process.war//process.core.remote.RequestFilter.filter(RequestFilter.java:20)
wildfly27_1 | at deployment.process.war//process.core.remote.RequestFilter$Proxy$_$$_WeldClientProxy.filter(Unknown Source)
wildfly27_1 | at [email protected]//org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.filterRequest(ClientInvocation.java:754)
wildfly27_1 | ... 7 more