hibernate/hibernate-orm · error · ServiceException
Bootstrap registry should only contain provided services
Error message
Bootstrap registry should only contain provided services
What it means
The BootstrapServiceRegistry only ever hosts services that were explicitly provided to it (ClassLoaderService, IntegratorService, and anything handed to the builder); it has no initiators. Its initiateService() unconditionally throws this ServiceException because initiating services is the job of the StandardServiceRegistry built on top. Hitting it means a service-role lookup was routed to the bootstrap registry for a role it never contained.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/registry/internal/BootstrapServiceRegistryImpl.java:237
}
}
private synchronized void destroy(ServiceBinding<?> serviceBinding) {
serviceBinding.getLifecycleOwner().stopService( serviceBinding );
}
public boolean isActive() {
return active;
}
@Override
public @Nullable ServiceRegistry getParentServiceRegistry() {
return null;
}
@Override
public <R extends Service> R initiateService(ServiceInitiator<R> serviceInitiator) {
throw new ServiceException( "Bootstrap registry should only contain provided services" );
}
@Override
public <R extends Service> void configureService(ServiceBinding<R> binding) {
throw new ServiceException( "Bootstrap registry should only contain provided services" );
}
@Override
public <R extends Service> void injectDependencies(ServiceBinding<R> binding) {
throw new ServiceException( "Bootstrap registry should only contain provided services" );
}
@Override
public <R extends Service> void startService(ServiceBinding<R> binding) {
throw new ServiceException( "Bootstrap registry should only contain provided services" );
}
@OverrideView on GitHub (pinned to fad1729dce)
Solutions
- Build a StandardServiceRegistry on top of the bootstrap registry (StandardServiceRegistryBuilder) and request standard services from it
- Only ask the bootstrap registry for the services it was given: ClassLoaderService, IntegratorService, JmxService and explicitly provided services
- Review custom ServiceContributor/Integrator code that manipulates registry internals
Example fix
// before BootstrapServiceRegistry boot = new BootstrapServiceRegistryBuilder().build(); JdbcServices jdbc = boot.getService(JdbcServices.class); // throws // after StandardServiceRegistry registry = new StandardServiceRegistryBuilder(boot).build(); JdbcServices jdbc = registry.getService(JdbcServices.class);
Defensive patterns
Strategy: validation
Validate before calling
// Verify the role is bootstrap-provided before lookup
static final Set<Class<?>> BOOTSTRAP_ROLES =
Set.of(ClassLoaderService.class, IntegratorService.class, JmxService.class);
if (!BOOTSTRAP_ROLES.contains(role)) {
throw new IllegalArgumentException(
role.getSimpleName() + " is a standard service - query the StandardServiceRegistry");
} Try / catch
try {
return registry.getService(role);
} catch (ServiceException e) {
if (e.getMessage().contains("Bootstrap registry")) {
// wrong registry level: build/wrap a StandardServiceRegistry and retry there
}
throw e;
} Prevention
- Request standard services only from a StandardServiceRegistry; bootstrap holds provided services only
- In tests, always build StandardServiceRegistryBuilder(bootstrap) before looking up services
- Document which services your integration needs and from which registry level
When it happens
Trigger: Calling getService()/requireService() for a non-provided role on a BootstrapServiceRegistry, or custom registry code that routes service initiation into the bootstrap registry - e.g., bootstrapRegistry.getService(JdbcServices.class) in an integration or test utility.
Common situations: Custom integrations or test scaffolding that hold only a BootstrapServiceRegistry and request standard services (JdbcServices, ConnectionProvider, ...); code copied from StandardServiceRegistryBuilder internals; frameworks wiring initiators at the wrong registry level.
Related errors
- #buildNamedQueryRepository should not be called on InFlightM
- Can't reactivate an active registry
- AbstractDelegatingMetadataBuildingOptions delegate did not i
- No ServiceRegistry was passed to Configuration#buildSessionF
- Could not locate JndiService from DataSourceBasedMultiTenant
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/6887053d76b92062.
Report an issue: GitHub.