{"record":{"id":"1efa6b9006464d50","repo":"quarkusio/quarkus","slug":"no-current-mutiny-statelesssession-found-no-rea","errorCode":null,"errorMessage":"No current Mutiny.StatelessSession found\n\t- no reactive stateless session was found in the Vert.x context and the context was not marked to open a new session lazily\n\t- a stateless session is opened automatically for JAX-RS resource methods annotated with an HTTP method (@GET, @POST, etc.); inherited annotations are not taken into account\n\t- you may need to annotate the business method with @Transactional, @WithStatelessSession or @WithStatelessTransaction","messagePattern":"No current Mutiny\\.StatelessSession found\n\t- no reactive stateless session was found in the Vert\\.x context and the context was not marked to open a new session lazily\n\t- a stateless session is opened automatically for JAX-RS resource methods annotated with an HTTP method \\(@GET, @POST, etc\\.\\); inherited annotations are not taken into account\n\t- you may need to annotate the business method with @Transactional, @WithStatelessSession or @WithStatelessTransaction","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/panache/hibernate-reactive-panache-common/runtime/src/main/java/io/quarkus/hibernate/reactive/panache/common/runtime/SessionOperations.java","lineNumber":342,"sourceCode":"        Context context = vertxContext();\n        // First make sure we don't already have an opened managed session\n        Uni<Mutiny.StatelessSession> error = checkNoManagedSession(context, persistenceUnitName);\n        if (error != null) {\n            return error;\n        }\n        Optional<OpenedSessionsState.SessionWithKey<Mutiny.StatelessSession>> opened = OPENED_SESSIONS_STATE_STATELESS\n                .getOpenedSession(context, persistenceUnitName);\n        if (opened.isPresent()) {\n            return Uni.createFrom().item(opened.get().session());\n        } else if (ContextLocals.get(context, SESSION_ON_DEMAND_KEY, null) != null) {\n            trackOnDemandSession(context, persistenceUnitName);\n            return Uni.createFrom()\n                    .item(() -> HibernateReactiveRecorder.getStatelessSession(persistenceUnitName, SESSION_ON_DEMAND_KEY));\n        } else if (ContextLocals.get(context, TRANSACTIONAL_METHOD_KEY, null) != null) {\n            return Uni.createFrom()\n                    .item(() -> HibernateReactiveRecorder.getStatelessSession(persistenceUnitName, TRANSACTIONAL_METHOD_KEY));\n        } else {\n            throw new IllegalStateException(\"No current Mutiny.StatelessSession found\"\n                    + \"\\n\\t- no reactive stateless session was found in the Vert.x context and the context was not marked to open a new session lazily\"\n                    + \"\\n\\t- a stateless session is opened automatically for JAX-RS resource methods annotated with an HTTP method (@GET, @POST, etc.); inherited annotations are not taken into account\"\n                    + \"\\n\\t- you may need to annotate the business method with @Transactional, @WithStatelessSession or @WithStatelessTransaction\");\n        }\n    }\n\n    /**\n     * @return the current reactive session stored in the context, or {@code null} if no session exists\n     */\n    public static Mutiny.Session getCurrentSession(String persistenceUnitName) {\n        Context context = vertxContext();\n        return OPENED_SESSIONS_STATE.getOpenedSession(context, persistenceUnitName)\n                .map(OpenedSessionsState.SessionWithKey::session)\n                .orElse(null);\n    }\n\n    /**\n     * @return the current reactive stateless session stored in the context, or {@code null} if no stateless session exists","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/panache/hibernate-reactive-panache-common/runtime/src/main/java/io/quarkus/hibernate/reactive/panache/common/runtime/SessionOperations.java#L324-L360","documentation":"SessionOperations.getStatelessSession mirrors getSession but for Mutiny.StatelessSession: it throws IllegalStateException when the Vert.x duplicated context holds neither a reactive stateless session nor a lazily-opened stateless session marker. Stateless-session Panache operations require the context to be managed by @WithStatelessSession/@WithStatelessTransaction/@Transactional (or a stateless JAX-RS setup). It is a context-propagation failure, not a query error.","triggerScenarios":"Calling stateless-session Panache operations (e.g. via StatelessSession-backed repositories, withStatelessSession APIs) from a context without markers: unannotated business methods, background threads losing the duplicated context, schedulers, or code relying on inherited HTTP annotations on a superclass.","commonSituations":"Mixing @WithSession (managed session) code paths with stateless APIs — the stateless lookup finds no stateless marker; calling stateless operations from a thread pool; forgetting @WithStatelessTransaction on an event consumer.","solutions":["Annotate the business method with @WithStatelessSession or @WithStatelessTransaction so a stateless session is opened on demand.","Use @Transactional if the operation is transactional and stateless-session backed.","Ensure the HTTP-verb annotation is directly on the JAX-RS resource method (inherited annotations are ignored).","Keep the work on the Vert.x duplicated context — do not hop threads with plain executors; use Mutiny emitOn with a context-preserving executor if needed.","If you actually need a managed session, switch to @WithSession/stateful APIs instead of stateless ones."],"exampleFix":"// before\npublic Uni<Product> refresh(Product p) {\n    return Panache.withStatelessSession(s -> s.refresh(p)); // no stateless session in context\n}\n\n// after\n@WithStatelessSession\npublic Uni<Product> refresh(Product p) {\n    return Panache.withStatelessSession(s -> s.refresh(p));\n}","handlingStrategy":"validation","validationCode":"if (Vertx.currentContext() == null || !statelessMarkersPresent()) {\n    throw new IllegalStateException(\"Stateless Panache calls require @WithStatelessSession/@WithStatelessTransaction on the calling method\");\n}","typeGuard":null,"tryCatchPattern":"try { return Panache.withStatelessSession(s -> s.refresh(p)); } catch (IllegalStateException e) { if (e.getMessage().startsWith(\"No current Mutiny.StatelessSession found\")) { log.error(\"Missing @WithStatelessSession annotation\", e); } throw e; }","preventionTips":["Use @WithStatelessSession/@WithStatelessTransaction (not @WithSession) for stateless APIs so the right marker is set","Do not mix managed-session and stateless-session APIs in one call chain","Keep stateless DB work on the Vert.x duplicated context; avoid thread hopping","Annotate the concrete JAX-RS method with its HTTP verb (inherited annotations are ignored)"],"tags":["hibernate-reactive","panache","vertx-context","stateless-session","reactive"],"backgroundTag":"no-current-vertx-session","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"}