quarkusio/quarkus · error · IllegalStateException

Attempting to boot a deactivated Hibernate Reactive persiste

Error message

Attempting to boot a deactivated Hibernate Reactive persistence unit

What it means

A persistence unit marked inactive at runtime (quarkus.hibernate-orm."name".active=false) must not be booted. If code still tries to obtain an EntityManagerFactory for it, Quarkus throws IllegalStateException to prevent using a deactivated PU.

Source

Thrown at extensions/hibernate-reactive/runtime/src/main/java/io/quarkus/hibernate/reactive/runtime/FastBootHibernateReactivePersistenceProvider.java:191

            if (!isProvider(persistenceUnit)) {
                log.debug("Excluding from consideration due to provider mismatch");
                continue;
            }

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

            final PrevalidatedQuarkusMetadata metadata = recordedState.getMetadata();
            final BuildTimeSettings buildTimeSettings = recordedState.getBuildTimeSettings();
            final IntegrationSettings integrationSettings = recordedState.getIntegrationSettings();
            RuntimeSettings.Builder runtimeSettingsBuilder = new RuntimeSettings.Builder(buildTimeSettings,
                    integrationSettings);
            SchemaToolingUtil.PreparedImportScripts importScripts = unzipZipFilesAndReplaceZipsInImportFiles(
                    runtimeSettingsBuilder);

            HibernateOrmRuntimeConfigPersistenceUnit persistenceUnitConfig = hibernateOrmRuntimeConfig.persistenceUnits()
                    .get(persistenceUnit.getName());
            if (persistenceUnitConfig.active().isPresent() && !persistenceUnitConfig.active().get()) {
                throw new IllegalStateException(
                        "Attempting to boot a deactivated Hibernate Reactive persistence unit");
            }

            // Inject runtime configuration if the persistence unit was defined by Quarkus configuration
            if (!recordedState.isFromPersistenceXml()) {
                injectRuntimeConfiguration(persistenceUnitConfig, runtimeSettingsBuilder);
            }

            for (HibernateOrmIntegrationRuntimeDescriptor descriptor : integrationRuntimeDescriptors
                    .getOrDefault(persistenceUnitName, Collections.emptyList())) {
                Optional<HibernateOrmIntegrationRuntimeInitListener> listenerOptional = descriptor.getInitListener();
                if (listenerOptional.isPresent()) {
                    listenerOptional.get().contributeRuntimeProperties(runtimeSettingsBuilder::put);
                }
            }

            boolean startsOffline = persistenceUnitConfig.database().startOffline();

View on GitHub (pinned to e1c734241f)

Solutions

  1. Set quarkus.hibernate-orm."<pu>".active=true for the profile where the PU is needed
  2. Guard code that touches the PU with the runtime config active() check before booting
  3. If PU is intentionally off, remove/rename it rather than leaving it inactive and referenced
  4. Check which profile (dev/test/prod) sets active=false

Example fix

// before
quarkus.hibernate-orm.reporting.active=false

// after (enable it, or guard usage)
quarkus.hibernate-orm.reporting.active=true
// or in code:
if (config.persistenceUnits().get("reporting").active().orElse(true)) { bootPu(); }
Defensive patterns

Strategy: validation

Validate before calling

HibernateOrmRuntimeConfig cfg = /* injected */;
HibernateOrmRuntimeConfigPersistenceUnit pu = cfg.persistenceUnits().get("reporting");
if (pu != null && pu.active().isPresent() && !pu.active().get()) {
    return; // skip boot
}

Type guard

boolean isActive(HibernateOrmRuntimeConfigPersistenceUnit pu) {
    return pu == null || pu.active().orElse(true);
}

Try / catch

try {
    return Persistence.createEntityManagerFactory(puName);
} catch (IllegalStateException e) {
    if (e.getMessage().contains("deactivated")) { return null; /* intentionally disabled */ }
    throw e;
}

Prevention

When it happens

Trigger: quarkus.hibernate-orm."<pu>".active=false (or quarkus.hibernate-orm.active=false) is set in configuration, and application code calls Persistence.createEntityManagerFactory for that PU, triggering getEntityManagerFactoryBuilderOrNull in FastBootHibernateReactivePersistenceProvider.

Common situations: Dev/test profiles disabling a PU (e.g., to avoid DB connection) while tests still touch it; environment-specific config deactivating the default PU; programmatically checking/iterating over all PUs including inactive ones.

Related errors


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