{"record":{"id":"57fa29ddb64dc4c5","repo":"apache/dubbo","slug":"method-not-found","errorCode":null,"errorMessage":"Method [{}] not found.","messagePattern":"Method \\[(.+?)\\] not found\\.","errorType":"exception","errorClass":"NoSuchMethodException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/Wrapper.java","lineNumber":103,"sourceCode":"        @Override\n        public Object invokeMethod(Object instance, String mn, Class<?>[] types, Object[] args)\n                throws NoSuchMethodException {\n            if (\"getClass\".equals(mn)) {\n                return instance.getClass();\n            }\n            if (\"hashCode\".equals(mn)) {\n                return instance.hashCode();\n            }\n            if (\"toString\".equals(mn)) {\n                return instance.toString();\n            }\n            if (\"equals\".equals(mn)) {\n                if (args.length == 1) {\n                    return instance.equals(args[0]);\n                }\n                throw new IllegalArgumentException(\"Invoke method [\" + mn + \"] argument number error.\");\n            }\n            throw new NoSuchMethodException(\"Method [\" + mn + \"] not found.\");\n        }\n    };\n    private static AtomicLong WRAPPER_CLASS_COUNTER = new AtomicLong(0);\n\n    /**\n     * get wrapper.\n     *\n     * @param c Class instance.\n     * @return Wrapper instance(not null).\n     */\n    public static Wrapper getWrapper(Class<?> c) {\n        return ConcurrentHashMapUtils.computeIfAbsent(WRAPPER_MAP, c, (clazz) -> {\n            while (ClassGenerator.isDynamicClass(clazz)) // can not wrapper on dynamic class.\n            {\n                clazz = clazz.getSuperclass();\n            }\n\n            if (clazz == Object.class) {","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/Wrapper.java#L85-L121","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nWrapper w = Wrapper.getWrapper(Object.class);\nw.invokeMethod(obj, \"doWork\", types, args);  // throws\n// after\nWrapper w = Wrapper.getWrapper(MyServiceImpl.class);\nw.invokeMethod(obj, \"doWork\", types, args);","handlingStrategy":"validation","validationCode":"Wrapper w = Wrapper.getWrapper(targetClass);\nif (!Arrays.asList(w.getMethodNames()).contains(methodName)\n    && !Arrays.asList(w.getDeclaredMethodNames()).contains(methodName)) {\n    // method not present; do not invoke\n}","typeGuard":"static boolean isKnownMethod(Wrapper w, String mn) {\n    return Arrays.asList(w.getMethodNames()).contains(mn);\n}","tryCatchPattern":"try {\n    wrapper.invokeMethod(instance, mn, types, args);\n} catch (NoSuchMethodException e) {\n    // method unknown to this wrapper; check target type\n}","preventionTips":["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."],"tags":["reflection","bytecode","wrapper","method-invocation","classloading"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}