{"record":{"id":"ca376f9b6a4c5d6c","repo":"hibernate/hibernate-orm","slug":"no-child-serviceregistry-registrations-found-ca376f","errorCode":null,"errorMessage":"No child ServiceRegistry registrations found","messagePattern":"No child ServiceRegistry registrations found","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java","lineNumber":419,"sourceCode":"\t\t\t\tSERVICE_LOGGER.unableToStopService( binding.getServiceRole().getName(), e );\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic synchronized void registerChild(@Nonnull ServiceRegistryImplementor child) {\n\t\tif ( childRegistries == null ) {\n\t\t\tchildRegistries = new HashSet<>();\n\t\t}\n\t\tif ( !childRegistries.add( child ) ) {\n\t\t\tSERVICE_LOGGER.warnf( \"Child ServiceRegistry [%s] was already registered; this will end badly later\", child );\n\t\t}\n\t}\n\n\t@Override\n\tpublic synchronized void deRegisterChild(@Nonnull ServiceRegistryImplementor child) {\n\t\tif ( childRegistries == null ) {\n\t\t\tthrow new IllegalStateException( \"No child ServiceRegistry registrations found\" );\n\t\t}\n\t\tchildRegistries.remove( child );\n\t\tif ( childRegistries.isEmpty() ) {\n\t\t\tif ( autoCloseRegistry ) {\n\t\t\t\tSERVICE_LOGGER.destroyingServiceRegistry();\n\t\t\t\tdestroy();\n\t\t\t}\n\t\t\telse {\n\t\t\t\tSERVICE_LOGGER.skippingDestroyingServiceRegistry();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Not intended for general use. We need the ability to stop and \"reactivate\" a registry to allow\n\t * experimentation with technologies such as GraalVM, Quarkus and Cri-O.\n\t */\n\tpublic synchronized void resetParent(@Nullable BootstrapServiceRegistry newParent) {","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java#L401-L437","documentation":"When a child registry closes, it calls deRegisterChild on its parent; if the parent's childRegistries set was never initialized (registerChild was never called with any child), the parent throws IllegalStateException(\"No child ServiceRegistry registrations found\"). It indicates broken parent/child wiring: this child was never actually registered with this parent, or deregistration is happening out of order.","triggerScenarios":"Building a SessionFactory against one BootstrapServiceRegistry but closing against a different instance; manual registry plumbing that skips the constructor's parent.registerChild; double-close paths where the first close already tore down the parent's child set.","commonSituations":"Application-managed factories created on separate bootstraps (e.g., per-tenant registries built inconsistently); test cleanup closing registries in the wrong order; older Hibernate versions with double-close bugs in SessionFactoryImpl shutdown.","solutions":["Use one shared BootstrapServiceRegistry for all StandardServiceRegistries/SessionFactories so parent-child links stay consistent","Close each SessionFactory and its registry exactly once, child before parent","Upgrade to the latest 6.x — several shutdown/double-close ordering fixes have landed","If you build registries manually, always construct children through APIs that call registerChild (the constructors do)"],"exampleFix":"// before\nBootstrapServiceRegistry b1 = new BootstrapServiceRegistryBuilder().build();\nStandardServiceRegistry r1 = new StandardServiceRegistryBuilder(b1).build();\n// later, accidentally: r1 built from b1, but something calls b2 (another instance).deRegisterChild(...)\n\n// after\n// one shared bootstrap for the whole application\nstatic final BootstrapServiceRegistry BOOTSTRAP = new BootstrapServiceRegistryBuilder().build();\nStandardServiceRegistry registry = new StandardServiceRegistryBuilder(BOOTSTRAP).build();\nSessionFactory sf = new MetadataBuilderImpl(registry).build().buildSessionFactory();\n// close once, in reverse order: sf.close() -> registry (auto-closed) -> BOOTSTRAP last","handlingStrategy":"try-catch","validationCode":"// ensure child was actually parented before closing it\n// (construct children only via StandardServiceRegistryBuilder(bootstrap))\nif (registry instanceof StandardServiceRegistryImpl impl) {\n    impl.close(); // child deregisters itself from its real parent\n}","typeGuard":null,"tryCatchPattern":"try {\n    bootstrapRegistry.close();\n}\ncatch (IllegalStateException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"No child ServiceRegistry\")) {\n        LOG.debug(\"children already deregistered/closed; nothing to do\", e);\n    }\n    else throw e;\n}","preventionTips":["Share one BootstrapServiceRegistry across all factories/registries in the application","Close each SessionFactory and registry exactly once, child before parent","Construct child registries only through builders so registerChild is always invoked"],"tags":["service-registry","lifecycle","shutdown"],"backgroundTag":"service-registry-misconfiguration","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}