apache/dubbo · error · IllegalStateException
Add default config failed: <configType.getSimpleName()>
Error message
Add default config failed: <configType.getSimpleName()>
What it means
Thrown by AbstractConfigManager.checkDefaultAndValidateConfigs() when adding a generated default config (for a required type lacking an explicit one) fails with any exception. The method first tries to create and refresh a default config; if that construction or refresh throws, it wraps the failure with the config type simple name. Validation or required-default logic surfaces here.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/config/context/AbstractConfigManager.java:621
*/
private Set<String> getConfigIdsFromProps(Class<? extends AbstractConfig> clazz) {
String prefix = CommonConstants.DUBBO + "." + AbstractConfig.getPluralTagName(clazz) + ".";
return ConfigurationUtils.getSubIds(environment.getConfigurationMaps(), prefix);
}
protected <T extends AbstractConfig> void checkDefaultAndValidateConfigs(Class<T> configType) {
try {
if (shouldAddDefaultConfig(configType)) {
T config = createConfig(configType, scopeModel);
config.refresh();
if (!isNeedValidation(config) || config.isValid()) {
this.addConfig(config);
} else {
logger.info("Ignore invalid config: " + config);
}
}
} catch (Exception e) {
throw new IllegalStateException("Add default config failed: " + configType.getSimpleName(), e);
}
// validate configs
Collection<T> configs = this.getConfigs(configType);
if (getConfigValidator() != null) {
for (T config : configs) {
getConfigValidator().validate(config);
}
}
// check required default
if (isRequired(configType) && configs.isEmpty()) {
throw new IllegalStateException("Default config not found for " + configType.getSimpleName());
}
}
/**
* The component configuration that does not affect the main process does not need to be verified.View on GitHub (pinned to 3a3043227f)
Solutions
- Provide an explicit config of the required type so the default-creation path is skipped.
- Inspect the wrapped cause to find why default construction failed.
- Ensure environment/properties needed by the default config are present.
Example fix
// before: relying on auto-default that fails
// (no application config, default creation throws)
// after: explicit config
ApplicationConfig app = new ApplicationConfig();
app.setName("myApp");
configManager.addConfig(app); Defensive patterns
Strategy: try-catch
Validate before calling
// Provide explicit required config to bypass default-creation path
if (configManager.getConfigs(ApplicationConfig.class).isEmpty()) {
ApplicationConfig app = new ApplicationConfig();
app.setName("myApp");
configManager.addConfig(app);
}
configManager.checkDefaultAndValidateConfigs(ApplicationConfig.class); Type guard
static boolean hasConfigOfType(ConfigManager cm, Class<? extends AbstractConfig> cls) {
return !cm.getConfigs(cls).isEmpty();
} Try / catch
try {
configManager.checkDefaultAndValidateConfigs(ApplicationConfig.class);
} catch (IllegalStateException e) {
if (e.getMessage().startsWith("Add default config failed")) {
ApplicationConfig app = new ApplicationConfig();
app.setName("myApp");
configManager.addConfig(app);
} else throw e;
} Prevention
- Always define required configs (application) explicitly in bootstrap.
- Set dubbo.application.name in Spring Boot properties.
- Write a startup smoke test that validates configs.
When it happens
Trigger: A config type marked for default creation whose default construction/refresh throws (e.g. default ApplicationConfig cannot resolve a required property). Called during the validate phase of bootstrap.
Common situations: Missing a required config and the auto-default path also fails due to environment issues (e.g. default registry address unresolvable). A custom required config type whose default builder is broken.
Related errors
- Invalid configurator rule, please specify at least one param
- service field in configuration is null.
- Illegal affinity rule!
- Illegal route rule!
- Illegal route rule!
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/cbb50954ee37c06b.
Report an issue: GitHub.