{"record":{"id":"1bae4c10b411893a","repo":"apache/dubbo","slug":"register-bean-failed-name-name-type-classna","errorCode":null,"errorMessage":"register bean failed! name=${name}, type=${className}","messagePattern":"register bean failed! name=(.+?), type=(.+?)","errorType":"exception","errorClass":"ScopeBeanException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/beans/factory/ScopeBeanFactory.java","lineNumber":206,"sourceCode":"            }\n        }\n        return bean;\n    }\n\n    private void initializeBean(String name, Object bean) {\n        checkDestroyed();\n        try {\n            if (bean instanceof ExtensionAccessorAware) {\n                ((ExtensionAccessorAware) bean).setExtensionAccessor(extensionAccessor);\n            }\n            for (ExtensionPostProcessor processor : extensionPostProcessors) {\n                processor.postProcessAfterInitialization(bean, name);\n            }\n            if (bean instanceof Initializable) {\n                ((Initializable) bean).initialize(extensionAccessor);\n            }\n        } catch (Exception e) {\n            throw new ScopeBeanException(\n                    \"register bean failed! name=\" + name + \", type=\"\n                            + bean.getClass().getName(),\n                    e);\n        }\n    }\n\n    @SuppressWarnings(\"SynchronizationOnLocalVariableOrMethodParameter\")\n    private void initializeBeanDefinitions(Class<?> type) {\n        for (int i = 0, size = registeredBeanDefinitions.size(); i < size; i++) {\n            BeanDefinition<?> definition = registeredBeanDefinitions.get(i);\n            if (definition.initialized) {\n                continue;\n            }\n\n            Class<?> beanClass = definition.beanClass;\n            if (!type.isAssignableFrom(beanClass)) {\n                continue;\n            }","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/beans/factory/ScopeBeanFactory.java#L188-L224","documentation":"Thrown by ScopeBeanFactory.registerBean(String, Object) during the post-registration lifecycle: setting the ExtensionAccessor, running all ExtensionPostProcessors, and calling Initializable.initialize(). If any of those steps throws, the whole registration is aborted and the cause is chained. The bean was constructed but failed to be wired/initialized.","triggerScenarios":"registerBean(name, instance) where the instance is ExtensionAccessorAware, or any registered ExtensionPostProcessor throws in postProcessAfterInitialization, or the bean implements Initializable and its initialize() throws.","commonSituations":"A bean's initialize() depends on an extension not yet loaded; a custom ExtensionPostProcessor fails on a specific bean; bean implements ExtensionAccessorAware and misuses the accessor; post-processor ordering changed after a Dubbo version upgrade.","solutions":["Inspect the chained cause to identify whether a post-processor or Initializable.initialize() failed.","Fix the failing initialize()/post-processor logic so it does not throw during registration.","Ensure required extensions/beans the initializer depends on are registered before this bean.","If using a custom ExtensionPostProcessor, make it defensive (skip beans it does not own) so it cannot break unrelated registrations."],"exampleFix":"// before\npublic class MyBean implements Initializable {\n    public void initialize(ExtensionAccessor a) {\n        this.dep = a.getExtension(Dep.class);  // throws if Dep missing\n    }\n}\n// after\npublic class MyBean implements Initializable {\n    public void initialize(ExtensionAccessor a) {\n        this.dep = Objects.requireNonNull(a.getExtension(Dep.class), \"Dep extension required\");\n    }\n}\n// and ensure Dep SPI is on the classpath before registering MyBean","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    factory.registerBean(name, bean);\n} catch (ScopeBeanException e) {\n    Throwable cause = e.getCause();\n    // cause originates from a post-processor or Initializable.initialize(); fix that path\n    log.error(\"Bean {} failed wiring/initialize\", name, cause);\n}","preventionTips":["Make Initializable.initialize() tolerant of missing optional dependencies.","Custom ExtensionPostProcessors should skip beans they do not own so they cannot break others.","Register dependencies before the bean whose initialize() needs them.","Inspect the chained cause to distinguish post-processor vs initialize failures."],"tags":["bean-factory","lifecycle","extension","dubbo-common"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}