apache/dubbo · error · IllegalArgumentException
Unsupported generic type <generic>
Error message
Unsupported generic type <generic>
What it means
Thrown by AbstractReferenceConfig.setGeneric() when the supplied generic value is not recognized by ProtocolUtils.isValidGenericValue(). Valid values are: 'true', 'false', 'nativejava', 'bean', 'protobuf', 'gson', 'raw.return' (case-insensitive). The generic setting controls generic invocation (generalized call) behavior for the reference, so an unknown value is rejected at config time rather than failing at invocation.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/config/AbstractReferenceConfig.java:182
@Deprecated
public void setGeneric(Boolean generic) {
if (generic != null) {
this.generic = generic.toString();
}
}
public String getGeneric() {
return generic;
}
public void setGeneric(String generic) {
if (StringUtils.isEmpty(generic)) {
return;
}
if (ProtocolUtils.isValidGenericValue(generic)) {
this.generic = generic;
} else {
throw new IllegalArgumentException("Unsupported generic type " + generic);
}
}
@Override
@Transient
protected boolean isNeedCheckMethod() {
return StringUtils.isEmpty(getGeneric());
}
/**
* @return
* @deprecated instead, use the parameter <b>scope</> to judge if it's in jvm, scope=local
*/
@Deprecated
public Boolean isInjvm() {
return injvm;
}
View on GitHub (pinned to 3a3043227f)
Solutions
- Use one of the valid generic values: 'true'/'false' (toggle), 'nativejava', 'bean', 'protobuf', 'gson', 'raw.return'.
- Leave generic unset if standard invocation is intended.
- For custom serialization, implement a proper generic filter extension rather than passing an arbitrary string.
Example fix
// before
referenceConfig.setGeneric("javabean");
// after
referenceConfig.setGeneric("bean"); Defensive patterns
Strategy: validation
Validate before calling
import org.apache.dubbo.rpc.support.ProtocolUtils;
String generic = "bean";
if (!ProtocolUtils.isValidGenericValue(generic)) {
throw new IllegalArgumentException("Invalid generic value: " + generic
+ ". Valid: true,false,nativejava,bean,protobuf,gson,raw.return");
}
referenceConfig.setGeneric(generic); Type guard
static boolean isValidGeneric(String g) {
return g == null || org.apache.dubbo.rpc.support.ProtocolUtils.isValidGenericValue(g);
} Try / catch
try {
referenceConfig.setGeneric(value);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unsupported generic type")) {
referenceConfig.setGeneric("true"); // fallback to default generic
} else throw e;
} Prevention
- Validate generic tokens against ProtocolUtils.isValidGenericValue before setting.
- Keep a list of valid generic values near config code.
- Treat custom serializer names as needing a proper SPI filter, not a generic string.
When it happens
Trigger: Calling referenceConfig.setGeneric("whatever") or setting <dubbo:reference generic="whatever"/> with an unrecognized string. Passing a custom serializer name that is not one of the built-in generic types.
Common situations: Typos such as 'generc', 'javabean', or using a value from a different RPC framework. Misremembering the valid tokens after a Dubbo upgrade that added/removed generic serializers.
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/24da3d9c4c027498.
Report an issue: GitHub.