apache/dubbo · error · IllegalStateException
Unable to get default scope model for type: ${type.getName()
Error message
Unable to get default scope model for type: ${type.getName()} What it means
The default branch of the switch over spi.scope() in getDefaultScopeModel(). SPI.Scope is a fixed enum (FRAMEWORK, APPLICATION, MODULE), so under normal conditions every value is handled and this branch is unreachable. Reaching it implies the enum was extended at runtime, a future-incompatible Dubbo version mismatch, or bytecode manipulation that introduced a new scope constant not understood by this build.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ScopeModelUtil.java:44
return scopeModel;
}
return getDefaultScopeModel(type);
}
private static <T> ScopeModel getDefaultScopeModel(Class<T> type) {
SPI spi = type.getAnnotation(SPI.class);
if (spi == null) {
throw new IllegalArgumentException("SPI annotation not found for class: " + type.getName());
}
switch (spi.scope()) {
case FRAMEWORK:
return FrameworkModel.defaultModel();
case APPLICATION:
return ApplicationModel.defaultModel();
case MODULE:
return ApplicationModel.defaultModel().getDefaultModule();
default:
throw new IllegalStateException("Unable to get default scope model for type: " + type.getName());
}
}
public static ModuleModel getModuleModel(ScopeModel scopeModel) {
if (scopeModel == null) {
return ApplicationModel.defaultModel().getDefaultModule();
}
if (scopeModel instanceof ModuleModel) {
return (ModuleModel) scopeModel;
} else {
throw new IllegalArgumentException("Unable to get ModuleModel from " + scopeModel);
}
}
public static ApplicationModel getApplicationModel(ScopeModel scopeModel) {
return getOrDefaultApplicationModel(scopeModel);
}
View on GitHub (pinned to 3a3043227f)
Solutions
- Align all Dubbo module versions to the same release (use a BOM / dependencyManagement to pin dubbo-bom).
- Run `mvn dependency:tree` (or gradle equivalent) and eliminate mismatched dubbo-* versions.
- If you forked Dubbo and added an SPI.Scope value, add a matching case to this switch.
- Upgrade dubbo-common to match the version that introduced the new scope constant.
Example fix
// not a user-code fix; resolve dependency versions
// before (mismatched): dubbo-common 3.0.x, dubbo-spi 3.1.x with new scope
// after: pin all via BOM
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-bom</artifactId>
<version>3.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> Defensive patterns
Strategy: validation
Validate before calling
// Defensive: verify the enum values this build knows match the runtime enum.
Set<String> known = Set.of("FRAMEWORK", "APPLICATION", "MODULE");
for (SPI.Scope s : SPI.Scope.values()) {
if (!known.contains(s.name())) {
throw new IllegalStateException("Unsupported SPI.Scope " + s + " — Dubbo version mismatch");
}
} Prevention
- Pin all dubbo-* artifacts to one version via dubbo-bom.
- Check dependency:tree for divergent Dubbo versions before release.
- Avoid mixing shaded Dubbo jars from different vendors.
When it happens
Trigger: A version of dubbo-common where SPI.Scope has an enum constant that this ScopeModelUtil switch does not case on (mixed-version jars on the classpath). Theoretically reachable via reflective enum injection. Practically a defensive guard against an internal contract change.
Common situations: Dependency conflicts: a newer dubbo-spi/extension module defines a new SPI.Scope value but dubbo-common is an older version. Shaded/relocated Dubbo jars from different vendors on the same classpath. Custom forks that add scope enum values without updating ScopeModelUtil.
Related errors
- Unable to get ExtensionLoader for type: ${type.getName()}
- ExtensionLoader for [${type}] is not found
- SPI annotation not found for class: ${type.getName()}
- There is no merger to merge result.
- No such class name in {}
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/9301683e15e59758.
Report an issue: GitHub.