apache/dubbo · error · IllegalStateException
<e.getMessage()>
Error message
<e.getMessage()>
What it means
Thrown by MethodConfig.convertMethodConfig2AsyncInfo when resolving the oninvoke/onreturn/onthrow callback methods fails for any reason. The original exception's message is propagated but wrapped in an IllegalStateException, masking the concrete type. It almost always indicates a misconfigured async callback (missing method, wrong signature, or null callback instance).
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/config/MethodConfig.java:302
asyncMethodInfo.setOninvokeInstance(getOninvoke());
asyncMethodInfo.setOnreturnInstance(getOnreturn());
asyncMethodInfo.setOnthrowInstance(getOnthrow());
try {
if (StringUtils.isNotEmpty(oninvokeMethod)) {
asyncMethodInfo.setOninvokeMethod(getMethodByName(getOninvoke().getClass(), oninvokeMethod));
}
if (StringUtils.isNotEmpty(onreturnMethod)) {
asyncMethodInfo.setOnreturnMethod(getMethodByName(getOnreturn().getClass(), onreturnMethod));
}
if (StringUtils.isNotEmpty(onthrowMethod)) {
asyncMethodInfo.setOnthrowMethod(getMethodByName(getOnthrow().getClass(), onthrowMethod));
}
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
return asyncMethodInfo;
}
private java.lang.reflect.Method getMethodByName(Class<?> clazz, String methodName) {
try {
return ReflectUtils.findMethodByMethodName(clazz, methodName);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
/**
* Set default field values of MethodConfig.
*
* @see org.apache.dubbo.config.annotation.Method
*/View on GitHub (pinned to 3a3043227f)
Solutions
- Verify the oninvoke/onreturn/onthrow method name exactly matches a public method on the callback instance, including signature.
- Ensure the oninvoke/onreturn/onthrow instance fields are set (not null) when the corresponding method-name fields are set.
- Check the original cause via getCause() on the IllegalStateException to see the underlying ReflectUtils error (e.g. NoSuchMethodException).
Example fix
// before @Method(name = "sayHello", oninvoke = "cb", oninvokeMethod = "onInoke") // typo // after @Method(name = "sayHello", oninvoke = "cb", oninvokeMethod = "onInvoke") // matches actual method
Defensive patterns
Strategy: validation
Validate before calling
// Validate callback methods exist before triggering convertMethodConfig2AsyncInfo
private void validateCallback(Object instance, String methodName) {
if (instance == null && methodName != null && !methodName.isEmpty()) {
throw new IllegalArgumentException("Callback instance missing for method " + methodName);
}
if (instance != null && methodName != null && !methodName.isEmpty()) {
ReflectUtils.findMethodByMethodName(instance.getClass(), methodName); // fail fast
}
} Try / catch
try {
AsyncMethodInfo info = methodConfig.convertMethodConfig2AsyncInfo();
} catch (IllegalStateException e) {
// cause carries the real reason (NoSuchMethodException, etc.)
Throwable root = e.getCause() != null ? e.getCause() : e;
log.error("Async callback config invalid for method {}: {}", methodConfig.getName(), root.getMessage());
throw e;
} Prevention
- Set the oninvoke/onreturn/onthrow instance whenever the corresponding method name is set.
- Use compile-time-checked callback method references instead of String names where possible.
- Add a startup self-test that resolves each callback method via reflection.
When it happens
Trigger: Configuring a MethodConfig with oninvoke/onreturn/onthrow method names whose target method does not exist on the corresponding callback object, or when the callback object (getOninvoke()/getOnreturn()/getOnthrow()) is null while its method name is set. The wrapping catch in convertMethodConfig2AsyncInfo re-throws any failure from getMethodByName.
Common situations: Typo in the oninvoke/onreturn/onthrow method name. Method signature mismatch (e.g. wrong parameter/return type). Setting oninvokeMethod without setting the oninvoke instance. Renaming a callback method in the implementation but not in the @Method annotation.
Related errors
- <e>
- Can not merge result because missing method [ {merger} ] in
- cannot find field %s,field is null
- Append parameters failed: <message>
- Failed to override field value of config bean: <this>
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/d3a5012f84437e81.
Report an issue: GitHub.