apache/dubbo · error · IllegalStateException

create config instance failed, id: <id>, type:<cls.getSimple

Error message

create config instance failed, id: <id>, type:<cls.getSimpleName()>

What it means

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.

Source

Thrown at dubbo-common/src/main/java/org/apache/dubbo/config/context/AbstractConfigManager.java:525

        return Optional.empty();
    }

    public abstract void loadConfigs();

    public <T extends AbstractConfig> List<T> loadConfigsOfTypeFromProps(Class<T> cls) {
        List<T> tmpConfigs = new ArrayList<>();
        PropertiesConfiguration properties = environment.getPropertiesConfiguration();

        // load multiple configs with id
        Set<String> configIds = this.getConfigIdsFromProps(cls);
        configIds.forEach(id -> {
            if (!this.getConfig(cls, id).isPresent()) {
                T config;
                try {
                    config = createConfig(cls, scopeModel);
                    config.setId(id);
                } catch (Exception e) {
                    throw new IllegalStateException(
                            "create config instance failed, id: " + id + ", type:" + cls.getSimpleName());
                }

                String key = null;
                boolean addDefaultNameConfig = false;
                try {
                    // add default name config (same as id), e.g. dubbo.protocols.rest.port=1234
                    key = DUBBO + "." + AbstractConfig.getPluralTagName(cls) + "." + id + ".name";
                    if (properties.getProperty(key) == null) {
                        properties.setProperty(key, id);
                        addDefaultNameConfig = true;
                    }

                    config.refresh();
                    this.addConfig(config);
                    tmpConfigs.add(config);
                } catch (Exception e) {
                    logger.error(

View on GitHub (pinned to 3a3043227f)

Solutions

  1. Inspect the original exception (it is swallowed; enable debug logging or reproduce createConfig directly) to find the root cause.
  2. Ensure the config class has a public no-arg or compatible constructor.
  3. Verify the config type is concrete and instantiable in the runtime environment.
  4. Check that required scope model/application model is available at construction time.

Example fix

// before: constructor throws
public MyConfig() { throw new IllegalStateException("init fail"); }
// after: defensive constructor
public MyConfig() { /* safe init */ }
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-validate that the config type is instantiable
try {
    AbstractConfig probe = type.getDeclaredConstructor().newInstance();
} catch (Exception e) {
    throw new IllegalStateException("Config type " + type.getSimpleName() + " is not instantiable", e);
}
configManager.loadConfigs(type);

Type guard

static boolean isInstantiableConfigType(Class<? extends AbstractConfig> cls) {
    try {
        cls.getDeclaredConstructor();
        return !java.lang.reflect.Modifier.isAbstract(cls.getModifiers());
    } catch (NoSuchMethodException e) {
        return false;
    }
}

Try / catch

try {
    configManager.loadConfigs(MyConfig.class);
} catch (IllegalStateException e) {
    if (e.getMessage().startsWith("create config instance failed")) {
        // inspect the real cause: log and fix constructor/properties
    } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14). Data as JSON: /api/errors/ae6ed12935d0f718. Report an issue: GitHub.