{"record":{"id":"7d122b4b9a696901","repo":"quarkusio/quarkus","slug":"mutiny-sessionfactory-bean-not-found","errorCode":null,"errorMessage":"Mutiny.SessionFactory bean not found","messagePattern":"Mutiny\\.SessionFactory bean not found","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/hibernate-reactive/runtime/src/main/java/io/quarkus/hibernate/reactive/runtime/OpenedSessionsState.java","lineNumber":132,"sourceCode":"    private BaseKey<T> createBaseKey(String persistenceUnitName) {\n        Mutiny.SessionFactory factory = sessionFactories.getValue(persistenceUnitName);\n        Implementor implementor = (Implementor) ClientProxy.unwrap(factory);\n        return new BaseKey<>(getSessionType(), implementor.getUuid());\n    }\n\n    private static Mutiny.SessionFactory createSessionFactory(String persistenceunitname) {\n        Mutiny.SessionFactory sessionFactory;\n\n        // Note that Mutiny.SessionFactory is @ApplicationScoped bean - it's safe to use the cached client proxy\n        if (DEFAULT_PERSISTENCE_UNIT_NAME.equals(persistenceunitname)) {\n            sessionFactory = Arc.container().instance(Mutiny.SessionFactory.class).get();\n        } else {\n            sessionFactory = Arc.container().instance(Mutiny.SessionFactory.class,\n                    new PersistenceUnit.PersistenceUnitLiteral(persistenceunitname)).get();\n        }\n\n        if (sessionFactory == null) {\n            throw new IllegalStateException(\"Mutiny.SessionFactory bean not found\");\n        }\n        return sessionFactory;\n    }\n}\n","sourceCodeStart":114,"sourceCodeEnd":137,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/hibernate-reactive/runtime/src/main/java/io/quarkus/hibernate/reactive/runtime/OpenedSessionsState.java#L114-L137","documentation":"OpenedSessionsState.createSessionFactory resolves the Mutiny.SessionFactory CDI bean for a specific persistence unit using a @PersistenceUnit qualifier. If ArC has no such bean (for that named persistence unit), this IllegalStateException is thrown, meaning the reactive session factory was never registered for that PU.","triggerScenarios":"Requesting a session for a persistence unit name that has no registered Mutiny.SessionFactory bean — typically a misspelled or nonexistent persistence unit name in @PersistenceUnit(\"name\")/@Inject, or bootstrapping before the Hibernate Reactive extension created the factory bean.","commonSituations":"Typos in persistence unit names in annotations or config; referencing a PU that only exists in the ORM (non-reactive) extension; ordering issues where a bean is resolved during startup before the PU is created; missing quarkus-hibernate-reactive configuration for that named PU.","solutions":["Verify the persistence unit name matches one defined via quarkus.hibernate-orm.<name>.* config properties (default PU uses no name/\"<default>\")","Ensure the injection/lookup uses the exact same name, e.g. @Inject @PersistenceUnit(\"myunit\") Mutiny.SessionFactory","Check that quarkus-hibernate-reactive (not just hibernate-orm) is configured for that persistence unit so the reactive SessionFactory bean exists","Inspect startup logs for PU creation errors — a failed PU creation leaves no SessionFactory bean"],"exampleFix":"// before\n@Inject\n@PersistenceUnit(\"prod-unit\")\nMutiny.SessionFactory sessionFactory; // name does not exist\n// after\n@Inject\n@PersistenceUnit(\"users\") // matches quarkus.hibernate-orm.users.* config\nMutiny.SessionFactory sessionFactory;","handlingStrategy":"validation","validationCode":"import io.quarkus.arc.Arc;\nimport io.quarkus.hibernate.orm.PersistenceUnit;\nimport org.hibernate.reactive.mutiny.Mutiny;\n\nMutiny.SessionFactory sf = Arc.container()\n    .instance(Mutiny.SessionFactory.class,\n        new PersistenceUnit.PersistenceUnitLiteral(\"users\"))\n    .get();\nif (sf == null) {\n    throw new IllegalStateException(\"No Mutiny.SessionFactory for PU 'users'; check quarkus.hibernate-orm.users.* config\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return sessionFactory.withTransaction(...);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"Mutiny.SessionFactory bean not found\")) {\n        throw new IllegalStateException(\"Persistence unit name has no reactive SessionFactory; verify @PersistenceUnit name and quarkus.hibernate-orm.<pu>.* config\", e);\n    }\n    throw e;\n}","preventionTips":["Keep persistence unit names in one shared constant and use it in @PersistenceUnit annotations","Ensure every named PU has quarkus.hibernate-orm.<name>.* reactive config, not only ORM config","Add a startup health check that resolves each expected Mutiny.SessionFactory bean early"],"tags":["quarkus","hibernate-reactive","cdi","persistence-unit","session-factory"],"backgroundTag":"missing-cdi-bean","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"}