{"record":{"id":"1c5363c6b2fd5acf","repo":"quarkusio/quarkus","slug":"no-instance-of-1-s-was-found-for-persistence-unit","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/HibernateCurrentTenantIdentifierResolver.java","lineNumber":71,"sourceCode":"\n    @Override\n    public boolean isRoot(String tenantId) {\n        // Make sure that we're in a request\n        if (!Arc.container().requestContext().isActive()) {\n            return false;\n        }\n        TenantResolver resolver = tenantResolver(persistenceUnitName);\n        if (resolver == null) {\n            return false;\n        }\n        return resolver.isRoot(tenantId);\n    }\n\n    private static TenantResolver tenantResolver(String persistenceUnitName) {\n        InjectableInstance<TenantResolver> instance = PersistenceUnitUtil.legacySingleExtensionInstanceForPersistenceUnit(\n                TenantResolver.class, persistenceUnitName);\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        return instance.get();\n    }\n\n}\n","sourceCodeStart":53,"sourceCodeEnd":80,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/tenant/HibernateCurrentTenantIdentifierResolver.java#L53-L80","documentation":"When a Hibernate ORM persistence unit is configured for multi-tenancy (quarkus.hibernate.orm.multi_tenancy.enabled=true), Quarkus resolves the current tenant via a CDI bean implementing TenantResolver. This error is thrown at runtime when no such bean exists for the persistence unit, so the CurrentTenantIdentifierResolver cannot determine the tenant.","triggerScenarios":"Multi-tenancy is enabled for a persistence unit but no @PersistenceUnitExtension bean implementing io.quarkus.hibernate.orm.runtime.tenant.TenantResolver is registered; the first Hibernate operation that needs the tenant identifier calls HibernateCurrentTenantIdentifierResolver.tenantResolver(persistenceUnitName) and the CDI instance is unsatisfied.","commonSituations":"Enabling quarkus.hibernate.orm.multi_tenancy.enabled without writing a TenantResolver implementation; forgetting @PersistenceUnitExtension (or legacy quarkus scope) on the implementation; the bean not being a CDI bean (missing bean-defining annotation); using a persistence unit name with no tenant bean registered for it.","solutions":["Create a CDI bean implementing TenantResolver and annotate it with @PersistenceUnitExtension for the target persistence unit","Implement getDefaultTenantId()/resolveCurrentTenantIdentifier() to return a non-null tenant id","Verify multi_tenancy.enabled=true is intentional; disable it if single-tenant","Rebuild/restart so the bean is discovered by ArC"],"exampleFix":"// before\n// no TenantResolver bean, multi-tenancy enabled -> IllegalStateException\n\n// after\n@PersistenceUnitExtension\n@ApplicationScoped\npublic class MyTenantResolver implements TenantResolver {\n    @Override\n    public String getDefaultTenantId() {\n        return CurrentRequestContext.getTenantId();\n    }\n}","handlingStrategy":"validation","validationCode":"boolean hasTenantResolver = CDI.current().select(TenantResolver.class).isResolvable();\nif (!hasTenantResolver && config.isMultiTenancyEnabled()) throw new IllegalStateException(\"Define a TenantResolver bean\");","typeGuard":"boolean tenantResolverPresent() {\n    return Arc.container() != null\n        && !Arc.container().instance(TenantResolver.class).isUnsatisfied();\n}","tryCatchPattern":"try {\n    em.find(Entity.class, id);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"TenantResolver\")) { failFast(\"Multi-tenancy misconfigured\"); }\n    throw e;\n}","preventionTips":["Always pair quarkus.hibernate.orm.multi_tenancy.enabled=true with a @PersistenceUnitExtension TenantResolver bean","Add a startup-time smoke test that resolves the current tenant","Keep resolver beans @ApplicationScoped so ArC discovers them"],"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-12T22:17:10.623Z"}