apache/dubbo · error · NoSuchMethodException
No such method ${methodName} in class ${clazz}
Error message
No such method ${methodName} in class ${clazz} What it means
ReflectUtils.findMethodByMethodSignature (deprecated) searches for a method by name (and optionally parameter types) on a class. When parameterTypes is null, it collects all methods matching the name. If none match, it throws NoSuchMethodException stating the method name and class. This signals the method simply does not exist on the target class.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/utils/ReflectUtils.java:908
* @return target method
* @throws NoSuchMethodException
* @throws ClassNotFoundException
* @throws IllegalStateException when multiple methods are found (overridden method when parameter info is not provided)
* @deprecated Recommend {@link MethodUtils#findMethod(Class, String, Class[])}
*/
@Deprecated
public static Method findMethodByMethodSignature(Class<?> clazz, String methodName, String[] parameterTypes)
throws NoSuchMethodException, ClassNotFoundException {
Method method;
if (parameterTypes == null) {
List<Method> found = new ArrayList<>();
for (Method m : clazz.getMethods()) {
if (m.getName().equals(methodName)) {
found.add(m);
}
}
if (found.isEmpty()) {
throw new NoSuchMethodException("No such method " + methodName + " in class " + clazz);
}
if (found.size() > 1) {
String msg = String.format(
"Not unique method for method name(%s) in class(%s), find %d methods.",
methodName, clazz.getName(), found.size());
throw new IllegalStateException(msg);
}
method = found.get(0);
} else {
Class<?>[] types = new Class<?>[parameterTypes.length];
for (int i = 0; i < parameterTypes.length; i++) {
types[i] = ReflectUtils.name2class(parameterTypes[i]);
}
method = clazz.getMethod(methodName, types);
}
return method;
}
View on GitHub (pinned to 3a3043227f)
Solutions
- Verify the method name spelling exactly matches a public method on the target class.
- Check for consumer/provider interface version mismatch — the method may have been added, renamed, or removed.
- Ensure the method is public (getMethods() only returns public methods).
- Prefer the non-deprecated clazz.getMethod(name, paramTypes) for new code, which gives clearer errors.
Example fix
// before
Method m = ReflectUtils.findMethodByMethodSignature(
MyService.class, "processData", null); // typo: actual is processData
// after
Method m = ReflectUtils.findMethodByMethodSignature(
MyService.class, "processData", null); Defensive patterns
Strategy: validation
Validate before calling
// Verify method exists by name before calling findMethodByMethodSignature
boolean exists = Arrays.stream(clazz.getMethods())
.anyMatch(m -> m.getName().equals(methodName));
if (!exists) {
throw new IllegalArgumentException(
"No public method '" + methodName + "' on " + clazz.getName());
}
ReflectUtils.findMethodByMethodSignature(clazz, methodName, null); Try / catch
try {
return ReflectUtils.findMethodByMethodSignature(clazz, methodName, paramTypes);
} catch (NoSuchMethodException e) {
logger.error("Method '{}' not found on {}. Check interface version.",
methodName, clazz.getName());
throw e;
} Prevention
- Verify method names at compile time by using typed service interfaces rather than string-based lookup.
- Keep consumer and provider interface versions in sync to avoid method name drift.
- Prefer clazz.getMethod(name, paramTypes) over the deprecated findMethodByMethodSignature for new code.
When it happens
Trigger: Calling ReflectUtils.findMethodByMethodSignature(clazz, methodName, null) where no method with the given methodName exists on clazz (or its supertypes). Since getMethods() returns all public methods including inherited ones, this means the method name is entirely absent from the public API.
Common situations: A Dubbo service consumer referencing a method name that doesn't exist on the provider interface — often due to a typo, a renamed method, or a version mismatch where the consumer's interface JAR has a method that was removed in the provider's version. Also in dynamic/generic invocation where method names are constructed programmatically and may be wrong.
Related errors
- Not unique method for method name(%s) in class(%s), find %d
- Can not merge result because missing method [ {merger} ] in
- Can not merge result: {e.getMessage()}
- unable to determine bean class from factory's superclass or
- create bean instance failed, type=${className}
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/4accfb25b72c4fd3.
Report an issue: GitHub.