{"record":{"id":"4accfb25b72c4fd3","repo":"apache/dubbo","slug":"no-such-method-methodname-in-class-clazz","errorCode":null,"errorMessage":"No such method ${methodName} in class ${clazz}","messagePattern":"No such method (.+?) in class (.+?)","errorType":"exception","errorClass":"NoSuchMethodException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/utils/ReflectUtils.java","lineNumber":908,"sourceCode":"     * @return target method\n     * @throws NoSuchMethodException\n     * @throws ClassNotFoundException\n     * @throws IllegalStateException  when multiple methods are found (overridden method when parameter info is not provided)\n     * @deprecated Recommend {@link MethodUtils#findMethod(Class, String, Class[])}\n     */\n    @Deprecated\n    public static Method findMethodByMethodSignature(Class<?> clazz, String methodName, String[] parameterTypes)\n            throws NoSuchMethodException, ClassNotFoundException {\n        Method method;\n        if (parameterTypes == null) {\n            List<Method> found = new ArrayList<>();\n            for (Method m : clazz.getMethods()) {\n                if (m.getName().equals(methodName)) {\n                    found.add(m);\n                }\n            }\n            if (found.isEmpty()) {\n                throw new NoSuchMethodException(\"No such method \" + methodName + \" in class \" + clazz);\n            }\n            if (found.size() > 1) {\n                String msg = String.format(\n                        \"Not unique method for method name(%s) in class(%s), find %d methods.\",\n                        methodName, clazz.getName(), found.size());\n                throw new IllegalStateException(msg);\n            }\n            method = found.get(0);\n        } else {\n            Class<?>[] types = new Class<?>[parameterTypes.length];\n            for (int i = 0; i < parameterTypes.length; i++) {\n                types[i] = ReflectUtils.name2class(parameterTypes[i]);\n            }\n            method = clazz.getMethod(methodName, types);\n        }\n        return method;\n    }\n","sourceCodeStart":890,"sourceCodeEnd":926,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ReflectUtils.java#L890-L926","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nMethod m = ReflectUtils.findMethodByMethodSignature(\n    MyService.class, \"processData\", null); // typo: actual is processData\n// after\nMethod m = ReflectUtils.findMethodByMethodSignature(\n    MyService.class, \"processData\", null);","handlingStrategy":"validation","validationCode":"// Verify method exists by name before calling findMethodByMethodSignature\nboolean exists = Arrays.stream(clazz.getMethods())\n    .anyMatch(m -> m.getName().equals(methodName));\nif (!exists) {\n    throw new IllegalArgumentException(\n        \"No public method '\" + methodName + \"' on \" + clazz.getName());\n}\nReflectUtils.findMethodByMethodSignature(clazz, methodName, null);","typeGuard":null,"tryCatchPattern":"try {\n    return ReflectUtils.findMethodByMethodSignature(clazz, methodName, paramTypes);\n} catch (NoSuchMethodException e) {\n    logger.error(\"Method '{}' not found on {}. Check interface version.\",\n        methodName, clazz.getName());\n    throw e;\n}","preventionTips":["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."],"tags":["reflection","method-lookup","deprecated","method-not-found"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}