apache/dubbo · error · IllegalArgumentException
Invalid scope model, expect to be a ApplicationModel but got
Error message
Invalid scope model, expect to be a ApplicationModel but got: <scopeModel>
What it means
Thrown by AbstractConfig.checkScopeModel during setScopeModel: the argument is not an instanceof ApplicationModel. The base AbstractConfig requires an ApplicationModel-level scope. Subclasses like Module-scoped configs override checkScopeModel to allow ModuleModel, but the default rejects anything else with IllegalArgumentException.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:458
@Transient
protected ScopeModel getDefaultModel() {
return ApplicationModel.defaultModel();
}
public final void setScopeModel(ScopeModel scopeModel) {
if (scopeModel != null && this.scopeModel != scopeModel) {
checkScopeModel(scopeModel);
ScopeModel oldScopeModel = this.scopeModel;
this.scopeModel = scopeModel;
// reinitialize spi extension and change referenced config's scope model
this.postProcessAfterScopeModelChanged(oldScopeModel, this.scopeModel);
}
}
protected void checkScopeModel(ScopeModel scopeModel) {
if (!(scopeModel instanceof ApplicationModel)) {
throw new IllegalArgumentException(
"Invalid scope model, expect to be a ApplicationModel but got: " + scopeModel);
}
}
/**
* Subclass should override this method to initialize its SPI extensions and change referenced config's scope model.
* <p>
* For example:
* <pre>
* protected void postProcessAfterScopeModelChanged() {
* super.postProcessAfterScopeModelChanged();
* // re-initialize spi extension
* this.protocol = this.getExtensionLoader(Protocol.class).getAdaptiveExtension();
* // change referenced config's scope model
* if (this.providerConfig != null && this.providerConfig.getScopeModel() != scopeModel) {
* this.providerConfig.setScopeModel(scopeModel);
* }
* }View on GitHub (pinned to 3a3043227f)
Solutions
- Pass an ApplicationModel instance to setScopeModel; derive one from a FrameworkModel via defaultApplicationModel().
- If the config should be module-scoped, override checkScopeModel in the subclass to accept ModuleModel.
- Do not setScopeModel with FrameworkModel or custom subtypes on base AbstractConfig.
- After a Dubbo upgrade, re-check the ScopeModel type expected by your config wiring.
Example fix
// before config.setScopeModel(moduleModel); // base AbstractConfig rejects this // after // use the application model (moduleModel.getApplicationModel()) config.setScopeModel(moduleModel.getApplicationModel());
Defensive patterns
Strategy: type-guard
Validate before calling
void setAppScopeModel(AbstractConfig cfg, ScopeModel m) {
if (!(m instanceof ApplicationModel)) {
throw new IllegalArgumentException("ApplicationModel required, got " + m);
}
cfg.setScopeModel(m);
} Type guard
boolean isApplicationModel(ScopeModel m) { return m instanceof ApplicationModel; } Try / catch
try {
config.setScopeModel(candidate);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Invalid scope model")) { /* pass ApplicationModel instead */ }
throw e;
} Prevention
- Resolve the ApplicationModel from whatever model you hold before setScopeModel.
- If a config must be module-scoped, override checkScopeModel to accept ModuleModel.
- Never pass FrameworkModel to a base AbstractConfig.
When it happens
Trigger: config.setScopeModel(someScopeModel) is called where someScopeModel is a FrameworkModel, a ModuleModel (on a config whose checkScopeModel isn't overridden to allow it), or a custom ScopeModel. Happens during explicit model assignment or when Dubbo internally propagates a model.
Common situations: Mixing a FrameworkModel where an ApplicationModel is expected (e.g. multi-ApplicationSet setups). Assigning a ModuleModel to a config type that only accepts ApplicationModel. Custom config subclass forgetting to override checkScopeModel when module-scoped.
Related errors
- scope model is invalid: <scopeModel>
- More than 1 default extension name on extension {}: {}
- url missing protocol: "<url>"
- <config>.<key> == null
- Append parameters failed: <message>
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/8ce0b5f281c1fd76.
Report an issue: GitHub.