quarkusio/quarkus · error · IllegalStateException

No REST request in progress

Error message

No REST request in progress

What it means

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.

Source

Thrown at independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/injection/ContextProducers.java:149

        return getContext().getDeployment().getApplicationSupplier().get();
    }

    @ApplicationScoped
    @Produces
    ResourceContext resourceContext() {
        return ResourceContextImpl.INSTANCE;
    }

    @RequestScoped
    @Produces
    SecurityContext securityContext() {
        return getContext().getSecurityContext();
    }

    private ResteasyReactiveRequestContext getContext() {
        ResteasyReactiveRequestContext context = CurrentRequestManager.get();
        if (context == null) {
            throw new IllegalStateException("No REST request in progress");
        }
        return context;
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Only access request-injected objects within the scope of an HTTP request handling thread
  2. Inject ResteasyReactiveRequestContext lazily and null-check via CurrentRequestManager.get() before use
  3. Pass needed values (URI, headers) as method parameters from the resource method instead
  4. Use @RunOnVirtualThread/executor carefully — capture values before leaving the request thread

Example fix

// before
@Scheduled(every="10s")
void job() { uriInfo.getPath(); } // no request in progress
// after
@Scheduled(every="10s")
void job() {
    var ctx = CurrentRequestManager.get();
    if (ctx != null) { /* use request info */ }
}
Defensive patterns

Strategy: validation

Validate before calling

var ctx = org.jboss.resteasy.reactive.server.core.CurrentRequestManager.get();
if (ctx == null) { /* not on a REST request thread — avoid request-scoped beans */ }

Type guard

static boolean inRestRequest() {
    return org.jboss.resteasy.reactive.server.core.CurrentRequestManager.get() != null;
}

Try / catch

try { return uriInfo.getPath(); } catch (IllegalStateException e) { if (e.getMessage().equals("No REST request in progress")) { return fallbackPath; } throw e; }

Prevention

When it happens

Trigger: 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).

Common situations: @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.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/731d4f198de638e7. Report an issue: GitHub.