apache/dubbo · warning · IllegalArgumentException
Current ServiceModel is not a ProviderModel
Error message
Current ServiceModel is not a ProviderModel
What it means
ServiceModel.getServiceConfig() is the deprecated counterpart of getReferenceConfig(): it returns the stored config only if it is a ServiceConfigBase (provider side). If the ServiceModel holds a ReferenceConfigBase (consumer side) or another config type, the cast is impossible and Dubbo throws. Deprecated because ServiceModel is being decoupled from AbstractInterfaceConfig.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ServiceModel.java:113
return (ReferenceConfigBase<?>) config;
} else {
throw new IllegalArgumentException("Current ServiceModel is not a ConsumerModel");
}
}
/**
* ServiceModel should be decoupled from AbstractInterfaceConfig and removed in a future version
* @return
*/
@Deprecated
public ServiceConfigBase<?> getServiceConfig() {
if (config == null) {
return null;
}
if (config instanceof ServiceConfigBase) {
return (ServiceConfigBase<?>) config;
} else {
throw new IllegalArgumentException("Current ServiceModel is not a ProviderModel");
}
}
public String getServiceKey() {
return serviceKey;
}
public void setProxyObject(Object proxyObject) {
this.proxyObject = proxyObject;
}
public Object getProxyObject() {
return proxyObject;
}
public ServiceDescriptor getServiceModel() {
return serviceModel;
}View on GitHub (pinned to 3a3043227f)
Solutions
- Guard the call: `if (serviceModel.getConfig() instanceof ServiceConfigBase) { ... }`.
- Use the non-deprecated, role-aware APIs and keep provider/consumer references separate instead of relying on ServiceModel.config.
- Only call getServiceConfig() on a model known to be a ProviderModel.
Example fix
// before (throws on a consumer ServiceModel)
ServiceConfigBase<?> svc = serviceModel.getServiceConfig();
// after
if (serviceModel.getConfig() instanceof ServiceConfigBase) {
ServiceConfigBase<?> svc = (ServiceConfigBase<?>) serviceModel.getConfig();
// use svc
} else {
// consumer or non-service model; handle accordingly
} Defensive patterns
Strategy: type-guard
Validate before calling
ServiceConfigBase<?> svc = null;
AbstractInterfaceConfig cfg = serviceModel.getConfig();
if (cfg instanceof ServiceConfigBase) {
svc = (ServiceConfigBase<?>) cfg;
} // else: not a provider model — do not call getServiceConfig() Type guard
static boolean isProviderModel(ServiceModel sm) {
return sm != null && sm.getConfig() instanceof ServiceConfigBase;
} Prevention
- Check getConfig() instanceof ServiceConfigBase before calling getServiceConfig().
- Prefer non-deprecated, role-aware APIs over ServiceModel config accessors.
- Only call getServiceConfig() on models known to be providers.
When it happens
Trigger: Calling serviceModel.getServiceConfig() on a consumer-side ServiceModel (config is a ReferenceConfigBase) or a model holding a non-service config. Reached when generic introspection assumes every ServiceModel is a provider.
Common situations: Registry/introspection code that calls getServiceConfig() on all ServiceModels regardless of role. Migration from older Dubbo where provider/consumer configs were not distinguished on ServiceModel. Reusing a ServiceModel reference captured on the consumer path.
Related errors
- Current ServiceModel is not a ConsumerModel
- Input type ${clazz} doesn't implement Extension ${type}
- Extension name is blank (Extension {})!
- Extension name {} doesn't exist (Extension {})!
- Adaptive Extension doesn't exist (Extension {})!
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/523b465e03056357.
Report an issue: GitHub.