{"record":{"id":"26aee0897b381123","repo":"quarkusio/quarkus","slug":"no-current-mutiny-session-found-no-reactive-ses","errorCode":null,"errorMessage":"No current Mutiny.Session found\n\t- no reactive session was found in the Vert.x context and the context was not marked to open a new session lazily\n\t- a 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, @WithSession or @WithTransaction","messagePattern":"No current Mutiny\\.Session found\n\t- no reactive session was found in the Vert\\.x context and the context was not marked to open a new session lazily\n\t- a 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, @WithSession or @WithTransaction","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":293,"sourceCode":"        Context context = vertxContext();\n        // First make sure we don't already have an opened stateless session\n        Uni<Mutiny.Session> error = checkNoStatelessSession(context, persistenceUnitName);\n        if (error != null) {\n            return error;\n        }\n        Optional<OpenedSessionsState.SessionWithKey<Mutiny.Session>> opened = OPENED_SESSIONS_STATE.getOpenedSession(context,\n                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.getSession(persistenceUnitName, SESSION_ON_DEMAND_KEY));\n        } else if (ContextLocals.get(context, TRANSACTIONAL_METHOD_KEY, null) != null) {\n            return Uni.createFrom()\n                    .item(() -> HibernateReactiveRecorder.getSession(persistenceUnitName, TRANSACTIONAL_METHOD_KEY));\n        } else {\n            throw new IllegalStateException(\"No current Mutiny.Session found\"\n                    + \"\\n\\t- no reactive session was found in the Vert.x context and the context was not marked to open a new session lazily\"\n                    + \"\\n\\t- a 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, @WithSession or @WithTransaction\");\n        }\n    }\n\n    /**\n     * If there is a reactive stateless session stored in the current Vert.x duplicated context then this stateless session is\n     * reused.\n     * <p>\n     * However, if there is no reactive stateless session found then:\n     * <ol>\n     * <li>if the current vertx duplicated context is marked as \"lazy\" then a new stateless session is opened and stored it in\n     * the\n     * context</li>\n     * <li>if the current context is marked as transactional then a new stateless session is created via the shared session\n     * state</li>\n     * <li>otherwise an exception thrown</li>","sourceCodeStart":275,"sourceCodeEnd":311,"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#L275-L311","documentation":"SessionOperations.getSession must obtain the current Mutiny.Session for a persistence unit from the Vert.x duplicated context. When no reactive session exists in the context and the context was not marked to open a session lazily (no @WithSession/@WithTransaction/@Transactional marker keys), it throws IllegalStateException with a multi-line diagnostic. Reactive sessions are propagated via Vert.x context locals, so Panache operations only work inside a managed reactive context (e.g. JAX-RS resource methods with an HTTP-annotation).","triggerScenarios":"Calling any Panache repository/active-record operation from a thread or code path without a Vert.x duplicated context carrying a Hibernate Reactive session marker: background threads, Vert.x worker/blocks, scheduled tasks, plain @ApplicationScoped business methods without @Transactional/@WithSession/@WithTransaction, or code run before the JAX-RS method marker is set.","commonSituations":"Business methods called from a REST resource but not annotated (inherited annotations from a base class are not honored); using CompletableFuture/executors that lose the context; Quarkus scheduler methods without @WithSession; calling Panache from a Kafka/AMQP consumer without a reactive transaction annotation.","solutions":["Annotate the business method with @WithSession (or @WithTransaction) so a session is opened lazily and stored in the Vert.x context.","If the method performs DB work transactionally, add @Transactional (which sets the transactional marker) instead.","For JAX-RS endpoints, ensure the HTTP-verb annotation (@GET/@POST/...) is on the method itself, not only on a superclass, since inherited annotations are not considered.","Capture the Vert.x duplicated context and rerun the work on that context (Vertx.getOrCreateContext().runOnContext(...)) when offloading to other threads.","For schedulers/messaging, wrap the handler with the reactive-session aware API or inject SessionOperations-managed scope via @WithSession."],"exampleFix":"// before\n@ApplicationScoped\npublic class UserService {\n    public Uni<User> find(long id) {\n        return User.findById(id); // IllegalStateException: no session\n    }\n}\n\n// after\n@ApplicationScoped\npublic class UserService {\n    @WithSession\n    public Uni<User> find(long id) {\n        return User.findById(id);\n    }\n}","handlingStrategy":"validation","validationCode":"if (Vertx.currentContext() == null || io.vertx.core.Context.isOnWorkerThread()) {\n    throw new IllegalStateException(\"Panache reactive calls require a Vert.x duplicated context; annotate the method with @WithSession/@WithTransaction\");\n}","typeGuard":null,"tryCatchPattern":"try { return User.findById(id); } catch (IllegalStateException e) { if (e.getMessage().startsWith(\"No current Mutiny.Session found\")) { log.error(\"Missing @WithSession/@Transactional on calling method\", e); } throw e; }","preventionTips":["Annotate every business method that touches Panache with @WithSession, @WithTransaction, or @Transactional","Never rely on inherited HTTP-verb annotations on JAX-RS superclasses; annotate the concrete method","Avoid hopping to plain executors/CompletableFuture around reactive DB code; stay in Mutiny chains on the Vert.x context","Annotate scheduler/messaging handlers explicitly (@WithSession/@WithTransaction)"],"tags":["hibernate-reactive","panache","vertx-context","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-14T00:17:10.932Z"}