{"record":{"id":"925e6df16754d415","repo":"quarkusio/quarkus","slug":"no-current-mutiny-session-found-you-need-to-ann","errorCode":null,"errorMessage":"No current Mutiny.Session found\n\t- you need to annotate your method with @Transactional to open a reactive session\n\t- alternatively, you can use @WithSessionOnDemand, @WithSession, or @WithTransaction\n\t- for JAX-RS resources, annotate the method directly with an HTTP method (@GET, @POST, etc.) to automatically open a session","messagePattern":"No current Mutiny\\.Session found\n\t- you need to annotate your method with @Transactional to open a reactive session\n\t- alternatively, you can use @WithSessionOnDemand, @WithSession, or @WithTransaction\n\t- for JAX-RS resources, annotate the method directly with an HTTP method \\(@GET, @POST, etc\\.\\) to automatically open a session","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/hibernate-reactive/runtime/src/main/java/io/quarkus/hibernate/reactive/runtime/HibernateReactiveRecorder.java","lineNumber":142,"sourceCode":"                };\n            }\n        };\n    }\n\n    public static Mutiny.Session getSession(String persistenceUnitName) {\n        return getSession(persistenceUnitName, TRANSACTIONAL_METHOD_KEY);\n    }\n\n    public static Mutiny.Session getSession(String persistenceUnitName, String contextKey) {\n        Context context = Vertx.currentContext();\n\n        Optional<OpenedSessionsState.SessionWithKey<Mutiny.Session>> openedSession = OPENED_SESSIONS_STATE.getOpenedSession(\n                context,\n                persistenceUnitName);\n        if (openedSession.isPresent()) {\n            return openedSession.get().session();\n        } else if (ContextLocals.get(contextKey).isEmpty()) {\n            throw new IllegalStateException(noSessionFoundErrorMessage());\n        } else {\n            // Store the persistence unit name so that we can close only this session at the end of the interceptor\n            ContextLocals.put(PERSISTENCE_UNIT_NAME_KEY, persistenceUnitName);\n            LOG.debugf(\"Opening lazy session for Persistence Unit '%s'\", persistenceUnitName);\n            return OPENED_SESSIONS_STATE.createNewSession(persistenceUnitName, context);\n        }\n    }\n\n    public Function<SyntheticCreationalContext<Mutiny.StatelessSession>, Mutiny.StatelessSession> statelessSessionSupplier(\n            String persistenceUnitName) {\n        return new Function<SyntheticCreationalContext<Mutiny.StatelessSession>, Mutiny.StatelessSession>() {\n\n            @Override\n            public Mutiny.StatelessSession apply(SyntheticCreationalContext<Mutiny.StatelessSession> context) {\n                return new MutinyStatelessSessionDelegator() {\n                    @Override\n                    public Mutiny.StatelessSession delegate() {\n                        return getStatelessSession(persistenceUnitName);","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/hibernate-reactive/runtime/src/main/java/io/quarkus/hibernate/reactive/runtime/HibernateReactiveRecorder.java#L124-L160","documentation":"Hibernate Reactive requires a session bound to the current Vert.x/Duplicate context. Quarkus opens one lazily only when an interceptor (e.g. @Transactional, @WithSession) has marked the context as session-enabled. If getSession is called with no such context marker, this IllegalStateException explains the annotations/HTTP-method markers that enable session creation.","triggerScenarios":"Calling a Mutiny.Session-producing API (e.g. via SessionMethodProvider / HibernateReactiveRecorder.getSession) from code running on a Vert.x context that was never marked by a session-opening interceptor — i.e. neither @Transactional, @WithSession, @WithSessionOnDemand, @WithTransaction, nor an annotated JAX-RS HTTP method is active on the call path.","commonSituations":"Calling repository/DAO methods from a startup event, scheduler, or non-annotated REST method; invoking session code inside @Scheduled or a plain CDI observer without @WithSession; forgetting @Transactional on a service method invoked outside a REST resource.","solutions":["Annotate the calling method with @WithSession (or @WithTransaction) so a reactive session is opened for the context","Add @Transactional to the method if transactional semantics are desired","For JAX-RS resources, annotate the endpoint method directly with @GET/@POST/etc. so the session opens automatically","If using @WithSessionOnDemand, ensure the session is accessed through the intended lazy provider path"],"exampleFix":"// before\npublic Uni<List<Fruit>> list() {\n  return sessionProvider.getSession()...\n}\n// after\n@WithSession\npublic Uni<List<Fruit>> list() {\n  return sessionProvider.getSession()...\n}","handlingStrategy":"validation","validationCode":"import io.quarkus.hibernate.orm.runtime.session.TransactionScopedSession;\nimport io.smallrye.mutiny.Uni;\n\n// Ensure the method that touches the session carries an opening annotation:\n// @WithSession / @WithTransaction / @Transactional on the calling method,\n// or an HTTP method annotation (@GET, @POST...) on the JAX-RS resource method.","typeGuard":null,"tryCatchPattern":"try {\n    return doQuery();\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"No current Mutiny.Session found\")) {\n        throw new IllegalStateException(\"Add @WithSession or @Transactional to the calling method (or annotate the REST method with @GET/@POST)\", e);\n    }\n    throw e;\n}","preventionTips":["Never access Mutiny.Session from code paths without a session-opening annotation in the same Vert.x context","For schedulers/startup code, always add @WithSession (or @WithTransaction)","Prefer annotating the business method rather than relying on ambient REST handling"],"tags":["quarkus","hibernate-reactive","session","context","annotations"],"backgroundTag":"no-current-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"}