{"record":{"id":"0c2ff022301943bc","repo":"quarkusio/quarkus","slug":"no-instance-of-1-s-was-found-for-persistence-unit-0c2ff0","errorCode":null,"errorMessage":"No instance of %1$s was found for persistence unit %2$s. You need to create an implementation for this interface to allow resolving the current tenant identifier.","messagePattern":"No instance of %1\\$s was found for persistence unit %2\\$s\\. You need to create an implementation for this interface to allow resolving the current tenant identifier\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/tenant/HibernateMultiTenantConnectionProvider.java","lineNumber":114,"sourceCode":"        if (cp == null) {\n            throw new IllegalStateException(\"Method 'TenantConnectionResolver.\"\n                    + \"resolve(String)' returned a null value. This violates the contract of the interface!\");\n        }\n        return cp;\n    }\n\n    /**\n     * Retrieves the tenant resolver or fails if it is not available.\n     *\n     * @return Current tenant resolver.\n     */\n    private static InstanceHandle<TenantResolver> tenantResolver(String persistenceUnitName) {\n        InjectableInstance<TenantResolver> instance = PersistenceUnitUtil\n                .legacySingleExtensionInstanceForPersistenceUnit(\n                        TenantResolver.class, persistenceUnitName);\n\n        if (instance.isUnsatisfied()) {\n            throw new IllegalStateException(String.format(Locale.ROOT,\n                    \"No instance of %1$s was found for persistence unit %2$s. \"\n                            + \"You need to create an implementation for this interface to allow resolving the current tenant identifier.\",\n                    TenantResolver.class.getSimpleName(), persistenceUnitName));\n        }\n\n        return instance.getHandle();\n    }\n\n}\n","sourceCodeStart":96,"sourceCodeEnd":124,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/tenant/HibernateMultiTenantConnectionProvider.java#L96-L124","documentation":"When obtaining the current tenant identifier for a connection in a multi-tenant persistence unit, Quarkus looks up a TenantResolver CDI bean. This error mirrors error 990 but is raised from HibernateMultiTenantConnectionProvider.tenantResolver when the bean is missing, so the tenant id needed to select the connection provider cannot be determined.","triggerScenarios":"quarkus.hibernate.orm.multi_tenancy.enabled=true; HibernateMultiTenantConnectionProvider needs the tenant id (e.g., getAnyConnectionProvider or getConnectionProvider path) and PersistenceUnitUtil.legacySingleExtensionInstanceForPersistenceUnit(TenantResolver.class, ...) is unsatisfied for the persistence unit.","commonSituations":"Enabling multi-tenancy without implementing TenantResolver; forgetting @PersistenceUnitExtension; bean not discoverable by CDI; multiple deployments with per-PU beans where one PU lacks a resolver.","solutions":["Create a @PersistenceUnitExtension-annotated CDI bean implementing TenantResolver","Return a non-null default tenant id in getDefaultTenantId()","Disable multi_tenancy if multi-tenancy was not intended","Rebuild the application so CDI bean discovery picks up the new bean"],"exampleFix":"// before\nquarkus.hibernate.orm.multi_tenancy.enabled=true\n// (no TenantResolver bean defined)\n\n// after\nquarkus.hibernate.orm.multi_tenancy.enabled=true\n// plus:\n@PersistenceUnitExtension\n@ApplicationScoped\npublic class HeaderTenantResolver implements TenantResolver {\n    @Override\n    public String getDefaultTenantId() { return \"base\"; }\n}","handlingStrategy":"validation","validationCode":"if (multiTenancyEnabled && !Arc.container().instance(TenantResolver.class).isResolvable()) {\n    throw new IllegalStateException(\"TenantResolver bean required for multi-tenancy\");\n}","typeGuard":"boolean canResolveTenant(String puName) {\n    return Arc.container() != null\n        && Arc.container().instance(TenantResolver.class).isResolvable();\n}","tryCatchPattern":"try {\n    return emf.createEntityManager();\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"resolving the current tenant identifier\")) { failFast(\"Missing TenantResolver\"); }\n    throw e;\n}","preventionTips":["Single source of truth: define TenantResolver once per persistence unit","Run an integration test that performs a tenant-scoped query at startup","Document the multi-tenancy bean contract in team guidelines"],"tags":["hibernate-orm","multi-tenancy","cdi","missing-bean"],"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-14T00:17:10.932Z"}