{"record":{"id":"731d4f198de638e7","repo":"quarkusio/quarkus","slug":"no-rest-request-in-progress","errorCode":null,"errorMessage":"No REST request in progress","messagePattern":"No REST request in progress","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/injection/ContextProducers.java","lineNumber":149,"sourceCode":"        return getContext().getDeployment().getApplicationSupplier().get();\n    }\n\n    @ApplicationScoped\n    @Produces\n    ResourceContext resourceContext() {\n        return ResourceContextImpl.INSTANCE;\n    }\n\n    @RequestScoped\n    @Produces\n    SecurityContext securityContext() {\n        return getContext().getSecurityContext();\n    }\n\n    private ResteasyReactiveRequestContext getContext() {\n        ResteasyReactiveRequestContext context = CurrentRequestManager.get();\n        if (context == null) {\n            throw new IllegalStateException(\"No REST request in progress\");\n        }\n        return context;\n    }\n}\n","sourceCodeStart":131,"sourceCodeEnd":154,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/injection/ContextProducers.java#L131-L154","documentation":"CDI producers for request-scoped JAX-RS objects (UriInfo, HttpHeaders, HttpServerRequest, etc.) call getContext(), which fetches the current ResteasyReactiveRequestContext from CurrentRequestManager. If no REST request is executing on the thread, there is no request context and IllegalStateException is thrown.","triggerScenarios":"Injecting @Inject UriInfo/HttpHeaders/ContainerRequestContext/ResteasyReactiveRequestContext into a bean used outside an active REST request (background task, scheduled job, startup event, plain gRPC/MQTT handler, or manually spawned thread).","commonSituations":"@Scheduled methods using request-scoped injected objects; accessing UriInfo from an event observer on ApplicationStarted; calling a bean from a Kafka consumer or executor thread; using request-bound beans in Uni/executor continuations that hop threads.","solutions":["Only access request-injected objects within the scope of an HTTP request handling thread","Inject ResteasyReactiveRequestContext lazily and null-check via CurrentRequestManager.get() before use","Pass needed values (URI, headers) as method parameters from the resource method instead","Use @RunOnVirtualThread/executor carefully — capture values before leaving the request thread"],"exampleFix":"// before\n@Scheduled(every=\"10s\")\nvoid job() { uriInfo.getPath(); } // no request in progress\n// after\n@Scheduled(every=\"10s\")\nvoid job() {\n    var ctx = CurrentRequestManager.get();\n    if (ctx != null) { /* use request info */ }\n}","handlingStrategy":"validation","validationCode":"var ctx = org.jboss.resteasy.reactive.server.core.CurrentRequestManager.get();\nif (ctx == null) { /* not on a REST request thread — avoid request-scoped beans */ }","typeGuard":"static boolean inRestRequest() {\n    return org.jboss.resteasy.reactive.server.core.CurrentRequestManager.get() != null;\n}","tryCatchPattern":"try { return uriInfo.getPath(); } catch (IllegalStateException e) { if (e.getMessage().equals(\"No REST request in progress\")) { return fallbackPath; } throw e; }","preventionTips":["Only use request-scoped injections inside HTTP request threads","Capture request data before hopping to executor/scheduler threads","Null-check CurrentRequestManager.get() in shared components"],"tags":["resteasy-reactive","cdi","request-scope","injection"],"backgroundTag":"no-request-context","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}