apache/dubbo · error · NoSuchMethodException
Method [{}] not found.
Error message
Method [{}] not found. What it means
Thrown by OBJECT_WRAPPER.invokeMethod when the requested method name is none of getClass, hashCode, toString, or equals. The Object-class wrapper only knows those four methods, so anything else is unknown to it.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/Wrapper.java:103
@Override
public Object invokeMethod(Object instance, String mn, Class<?>[] types, Object[] args)
throws NoSuchMethodException {
if ("getClass".equals(mn)) {
return instance.getClass();
}
if ("hashCode".equals(mn)) {
return instance.hashCode();
}
if ("toString".equals(mn)) {
return instance.toString();
}
if ("equals".equals(mn)) {
if (args.length == 1) {
return instance.equals(args[0]);
}
throw new IllegalArgumentException("Invoke method [" + mn + "] argument number error.");
}
throw new NoSuchMethodException("Method [" + mn + "] not found.");
}
};
private static AtomicLong WRAPPER_CLASS_COUNTER = new AtomicLong(0);
/**
* get wrapper.
*
* @param c Class instance.
* @return Wrapper instance(not null).
*/
public static Wrapper getWrapper(Class<?> c) {
return ConcurrentHashMapUtils.computeIfAbsent(WRAPPER_MAP, c, (clazz) -> {
while (ClassGenerator.isDynamicClass(clazz)) // can not wrapper on dynamic class.
{
clazz = clazz.getSuperclass();
}
if (clazz == Object.class) {View on GitHub (pinned to 3a3043227f)
Solutions
- Ensure the class passed to Wrapper.getWrapper is the real service interface/class, not Object.
- Verify the service interface is on the classpath and loaded by the correct ClassLoader so getWrapper does not fall back to OBJECT_WRAPPER.
- Check that the method name in the invocation matches an actual method on the target type.
Example fix
// before Wrapper w = Wrapper.getWrapper(Object.class); w.invokeMethod(obj, "doWork", types, args); // throws // after Wrapper w = Wrapper.getWrapper(MyServiceImpl.class); w.invokeMethod(obj, "doWork", types, args);
Defensive patterns
Strategy: validation
Validate before calling
Wrapper w = Wrapper.getWrapper(targetClass);
if (!Arrays.asList(w.getMethodNames()).contains(methodName)
&& !Arrays.asList(w.getDeclaredMethodNames()).contains(methodName)) {
// method not present; do not invoke
} Type guard
static boolean isKnownMethod(Wrapper w, String mn) {
return Arrays.asList(w.getMethodNames()).contains(mn);
} Try / catch
try {
wrapper.invokeMethod(instance, mn, types, args);
} catch (NoSuchMethodException e) {
// method unknown to this wrapper; check target type
} Prevention
- Confirm the class passed to getWrapper is the real service type, not Object.
- Ensure service interfaces are on the classpath and loaded by the correct ClassLoader.
- Check method-name spelling against the target interface.
When it happens
Trigger: Calling wrapper.invokeMethod on a Wrapper that resolved to OBJECT_WRAPPER with a method name outside the Object method set (e.g. "foo", "bar"). Occurs when the wrapped class is java.lang.Object or a dynamic class whose non-dynamic superclass is Object.
Common situations: The target interface/class resolved to Object.class after the isDynamicClass loop in getWrapper, so no real method table was generated. Common when a service reference points to a raw Object or an interface that could not be loaded, falling back to Object.
Related errors
- Invoke method [{}] argument number error.
- Property [{}] not found.
- Can not create wrapper for primitive type: {}
- Unknown primitive type: {}
- Can not merge result: {e.getMessage()}
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/57fa29ddb64dc4c5.
Report an issue: GitHub.