hibernate/hibernate-orm · error · IllegalStateException

Can't reactivate an active registry

Error message

Can't reactivate an active registry

What it means

resetAndReactivate() is an @Internal method that lets a stopped StandardServiceRegistry be revived for experimentation with GraalVM/Quarkus-style boot. It refuses to run while the registry is still active - reactivating live service state would corrupt it - so isActive() == true yields IllegalStateException before any state is touched.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/registry/internal/StandardServiceRegistryImpl.java:121

		}
		catch (RuntimeException e) {
			visitServiceBindings( binding -> binding.getLifecycleOwner().stopService( binding ) );
			throw e;
		}
	}

	/**
	 * Not intended for general use. We need the ability to stop and "reactivate" a registry
	 * to allow experimentation with technologies such as GraalVM, Quarkus and Cri-O.
	 */
	@Internal
	public synchronized void resetAndReactivate(
			BootstrapServiceRegistry bootstrapServiceRegistry,
			List<StandardServiceInitiator<?>> serviceInitiators,
			List<ProvidedService<?>> providedServices,
			Map<?, ?> configurationValues) {
		if ( super.isActive() ) {
			throw new IllegalStateException( "Can't reactivate an active registry" );
		}
		super.resetParent( bootstrapServiceRegistry );
		this.configurationValues = new HashMap( configurationValues );
		super.reactivate();
		applyServiceRegistrations( serviceInitiators, providedServices );
	}


	@Override
	public synchronized <R extends Service> R initiateService(ServiceInitiator<R> serviceInitiator) {
		// todo : add check/error for unexpected initiator types?
		return ( (StandardServiceInitiator<R>) serviceInitiator ).initiateService( configurationValues, this );
	}

	@Override
	public synchronized <R extends Service> void configureService(ServiceBinding<R> serviceBinding) {
		if ( serviceBinding.getService() instanceof Configurable configurable ) {
			configurable.configure( configurationValues );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Ensure the registry is fully stopped (destroy()) before resetAndReactivate(), and investigate why the prior shutdown did not happen
  2. Prefer building a fresh StandardServiceRegistry per restart instead of reactivating the old one
  3. Do not call @Internal APIs from application code; upgrade the framework (Quarkus/Hibernate) where restart sequencing is fixed
Defensive patterns

Strategy: validation

Validate before calling

// Only reactivate a registry that is actually stopped
if (registry.isActive()) {
    registry.destroy(); // or skip reactivation entirely and build a fresh registry
}
registry.resetAndReactivate(boot, initiators, provided, config);

Try / catch

try {
    registry.resetAndReactivate(...);
} catch (IllegalStateException e) {
    if (e.getMessage().contains("reactivate an active registry")) {
        // previous shutdown never completed: fall back to a freshly built registry
    }
    throw e;
}

Prevention

When it happens

Trigger: Framework boot code (Quarkus dev-mode restarts, native-image bootstraps, custom restart logic) calling resetAndReactivate() without a prior successful stop/destroy of the registry - typically because an earlier shutdown failed, was skipped, or raced with the restart.

Common situations: Quarkus dev-mode/hot-reload restart sequences; custom bootstraps that reuse one registry across restarts; exceptions during a previous close leaving the registry marked active.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/a5a6c13f67a943d7. Report an issue: GitHub.