quarkusio/quarkus · error · IllegalStateException

Attempting to boot a deactivated Hibernate ORM persistence u

Error message

Attempting to boot a deactivated Hibernate ORM persistence unit

What it means

A persistence unit deactivated at runtime via quarkus.hibernate-orm."<pu>".active=false is intentionally not booted. When code still requests its EntityManagerFactory, getEntityManagerFactoryBuilderOrNull throws IllegalStateException('Attempting to boot a deactivated Hibernate ORM persistence unit').

Source

Thrown at extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/FastBootHibernatePersistenceProvider.java:211

                continue;
            }

            // See if we (Hibernate) are the persistence provider
            if (!isProvider(persistenceUnit)) {
                log.debug("Excluding from consideration due to provider mismatch");
                continue;
            }

            RecordedState recordedState = PersistenceUnitsHolder.popRecordedState(persistenceUnitName, false);

            if (recordedState.isReactive()) {
                throw new IllegalStateException(
                        "Attempting to boot a blocking Hibernate ORM instance on a reactive RecordedState");
            }
            final PrevalidatedQuarkusMetadata metadata = recordedState.getMetadata();
            var puConfig = hibernateOrmRuntimeConfig.persistenceUnits().get(persistenceUnit.getName());
            if (puConfig.active().isPresent() && !puConfig.active().get()) {
                throw new IllegalStateException(
                        "Attempting to boot a deactivated Hibernate ORM persistence unit");
            }
            RuntimeSettingsResult runtimeSettingsResult = buildRuntimeSettings(persistenceUnitName, recordedState,
                    puConfig);

            StandardServiceRegistry standardServiceRegistry = rewireMetadataAndExtractServiceRegistry(persistenceUnitName,
                    recordedState, puConfig, runtimeSettingsResult.settings());

            final Object cdiBeanManager = Arc.container().beanManager();
            final Object validatorFactory = Arc.container().instance("quarkus-hibernate-validator-factory").get();

            return new FastBootEntityManagerFactoryBuilder(
                    persistenceUnit,
                    metadata /* Uses the StandardServiceRegistry references by this! */,
                    standardServiceRegistry /* Mostly ignored! (yet needs to match) */,
                    runtimeSettingsResult.settings(),
                    validatorFactory, cdiBeanManager, recordedState.getMultiTenancyStrategy(),
                    true,

View on GitHub (pinned to e1c734241f)

Solutions

  1. Remove active=false (or set it true) for PUs actually used at runtime.
  2. Update code referencing the deactivated PU, or guard it behind configuration checks.
  3. Audit profiles that set active=false and align them with actual usage.
  4. Check HibernateOrmRuntimeConfig/activation state before requesting the factory in custom code.

Example fix

// before (application.properties)
quarkus.hibernate-orm."audit".active=false
// after
quarkus.hibernate-orm."audit".active=true
// or remove references to the 'audit' PU in code
Defensive patterns

Strategy: validation

Validate before calling

var cfg = HibernateOrmRuntimeConfigHelper puConfig("audit");
if (cfg != null && cfg.active().isPresent() && !cfg.active().get()) {
    throw new IllegalStateException("PU 'audit' is deactivated; do not request its EMF");
}

Try / catch

try {
    emf = bootPu("audit");
} catch (IllegalStateException e) {
    if (e.getMessage().contains("deactivated Hibernate ORM persistence unit")) {
        log.warn("PU 'audit' disabled by config; skipping");
        emf = null;
    } else throw e;
}

Prevention

When it happens

Trigger: getEntityManagerFactoryBuilderOrNull reads puConfig.active() for the requested PU, finds it present and false, and throws; reached via builder or getEntityManagerFactoryBuilder.

Common situations: Named PUs trimmed via active=false but still referenced by code; active flipped by a profile (e.g. %%test) while tests still inject the EM; dynamic activation logic computing active=false incorrectly.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/96659f8efb2c811b. Report an issue: GitHub.