{"record":{"id":"ae6ed12935d0f718","repo":"apache/dubbo","slug":"create-config-instance-failed-id-id-type-cls","errorCode":null,"errorMessage":"create config instance failed, id: <id>, type:<cls.getSimpleName()>","messagePattern":"create config instance failed, id: <id>, type:<cls\\.getSimpleName\\(\\)>","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/config/context/AbstractConfigManager.java","lineNumber":525,"sourceCode":"        return Optional.empty();\n    }\n\n    public abstract void loadConfigs();\n\n    public <T extends AbstractConfig> List<T> loadConfigsOfTypeFromProps(Class<T> cls) {\n        List<T> tmpConfigs = new ArrayList<>();\n        PropertiesConfiguration properties = environment.getPropertiesConfiguration();\n\n        // load multiple configs with id\n        Set<String> configIds = this.getConfigIdsFromProps(cls);\n        configIds.forEach(id -> {\n            if (!this.getConfig(cls, id).isPresent()) {\n                T config;\n                try {\n                    config = createConfig(cls, scopeModel);\n                    config.setId(id);\n                } catch (Exception e) {\n                    throw new IllegalStateException(\n                            \"create config instance failed, id: \" + id + \", type:\" + cls.getSimpleName());\n                }\n\n                String key = null;\n                boolean addDefaultNameConfig = false;\n                try {\n                    // add default name config (same as id), e.g. dubbo.protocols.rest.port=1234\n                    key = DUBBO + \".\" + AbstractConfig.getPluralTagName(cls) + \".\" + id + \".name\";\n                    if (properties.getProperty(key) == null) {\n                        properties.setProperty(key, id);\n                        addDefaultNameConfig = true;\n                    }\n\n                    config.refresh();\n                    this.addConfig(config);\n                    tmpConfigs.add(config);\n                } catch (Exception e) {\n                    logger.error(","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/config/context/AbstractConfigManager.java#L507-L543","documentation":"Thrown by AbstractConfigManager during bulk config loading when createConfig() (which reflectively instantiates a config of the given type and sets its id) fails with any exception. The wrapping IllegalStateException hides the original cause but records the id and config type, pointing to a constructor or instantiation problem for that specific config entry.","triggerScenarios":"A config type whose required-arg constructor throws, a class that cannot be reflectively instantiated (abstract, no public ctor, or ctor throws), or a scope model mismatch during construction. Triggered per-id during loadConfigsFromProps-style loading.","commonSituations":"A custom AbstractConfig subclass with a constructor that throws on certain inputs. Security manager or module-access restrictions blocking reflective instantiation. Passing a non-instantiable config type to the loader.","solutions":["Inspect the original exception (it is swallowed; enable debug logging or reproduce createConfig directly) to find the root cause.","Ensure the config class has a public no-arg or compatible constructor.","Verify the config type is concrete and instantiable in the runtime environment.","Check that required scope model/application model is available at construction time."],"exampleFix":"// before: constructor throws\npublic MyConfig() { throw new IllegalStateException(\"init fail\"); }\n// after: defensive constructor\npublic MyConfig() { /* safe init */ }","handlingStrategy":"try-catch","validationCode":"// Pre-validate that the config type is instantiable\ntry {\n    AbstractConfig probe = type.getDeclaredConstructor().newInstance();\n} catch (Exception e) {\n    throw new IllegalStateException(\"Config type \" + type.getSimpleName() + \" is not instantiable\", e);\n}\nconfigManager.loadConfigs(type);","typeGuard":"static boolean isInstantiableConfigType(Class<? extends AbstractConfig> cls) {\n    try {\n        cls.getDeclaredConstructor();\n        return !java.lang.reflect.Modifier.isAbstract(cls.getModifiers());\n    } catch (NoSuchMethodException e) {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    configManager.loadConfigs(MyConfig.class);\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"create config instance failed\")) {\n        // inspect the real cause: log and fix constructor/properties\n    } else throw e;\n}","preventionTips":["Ensure custom config types have a public no-arg constructor.","Unit-test reflective instantiation of custom config types.","Log the original cause during debugging since it is wrapped."],"tags":["config","instantiation","reflection","config-loading"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}