{"record":{"id":"2402135dbf43fa9b","repo":"apache/seatunnel","slug":"method-invoke-failed-no-such-method-s-in-s","errorCode":null,"errorMessage":"method invoke failed, no such method '%s' in '%s'","messagePattern":"method invoke failed, no such method '(.+?)' in '(.+?)'","errorType":"exception","errorClass":"NoSuchMethodException","httpStatus":null,"severity":"error","filePath":"seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/ReflectionUtils.java","lineNumber":99,"sourceCode":"    }\n\n    public static Object invoke(Object object, String methodName, Object... args) {\n        Class<?>[] argTypes = new Class[args.length];\n        for (int i = 0; i < args.length; i++) {\n            argTypes[i] = args[i].getClass();\n        }\n        return invoke(object, methodName, argTypes, args);\n    }\n\n    public static Object invoke(\n            Object object, String methodName, Class<?>[] argTypes, Object[] args) {\n        try {\n            Optional<Method> method = getDeclaredMethod(object.getClass(), methodName, argTypes);\n            if (method.isPresent()) {\n                method.get().setAccessible(true);\n                return method.get().invoke(object, args);\n            } else {\n                throw new NoSuchMethodException(\n                        String.format(\n                                \"method invoke failed, no such method '%s' in '%s'\",\n                                methodName, object.getClass()));\n            }\n        } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {\n            throw new RuntimeException(\"method invoke failed\", e);\n        }\n    }\n}\n","sourceCodeStart":81,"sourceCodeEnd":109,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/ReflectionUtils.java#L81-L109","documentation":"ReflectionUtils.invoke looks up a declared method on the target object's class by name and argument types; if no matching method exists it throws NoSuchMethodException with this formatted message naming the method and class. The public invoke() wrapper immediately catches it and rethrows as a RuntimeException, so callers see 'method invoke failed' with the missing-method detail as the cause. This is a defensive helper used for reflective access to classes that may not be on the compile-time classpath.","triggerScenarios":"Calling ReflectionUtils.invoke(obj, 'methodName', argTypes, args) where the method name is misspelled, the argTypes array does not match any declared method signature (wrong order, wrong types, primitives vs boxed), or the target class version simply lacks the method.","commonSituations":"Version drift between SeaTunnel and a plugin/connector dependency: code reflects on a method that was renamed or removed in a newer library version; typos in method names after refactoring; passing Class<?>[] with autoboxed types where the declared method uses primitives.","solutions":["Verify the exact method name and declared parameter types against the target class (javap or IDE) and fix the name/argTypes passed to invoke","Check dependency versions so the reflected class matches the expected library version","If a primitive parameter is expected, pass e.g. int.class not Integer.class in argTypes","Catch the RuntimeException and inspect the NoSuchMethodException cause to print the attempted signature"],"exampleFix":"// before\nReflectionUtils.invoke(obj, \"getSplits\", new Class[]{Integer.class}, 4);\n// after\nReflectionUtils.invoke(obj, \"getSplits\", new Class[]{int.class}, 4);","handlingStrategy":"type-guard","validationCode":"java.util.Optional<java.lang.reflect.Method> m =\n    ReflectionUtils.getDeclaredMethod(obj.getClass(), \"getSplits\", new Class[]{int.class});\nif (!m.isPresent()) { throw new IllegalStateException(\"missing method on \" + obj.getClass()); }","typeGuard":"boolean hasMethod(Object o, String name, Class<?>... types) {\n  try { o.getClass().getMethod(name, types); return true; }\n  catch (NoSuchMethodException e) { return false; }\n}","tryCatchPattern":"try {\n  return ReflectionUtils.invoke(obj, methodName, argTypes, args);\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof NoSuchMethodException) {\n    throw new IllegalStateException(\"Method \" + methodName + \" missing on \" + obj.getClass(), e);\n  }\n  throw e;\n}","preventionTips":["Verify signatures with javap or IDE against the exact dependency version in use","Pin dependency versions so reflective targets exist at runtime","Prefer passing exact primitive .class tokens (int.class) over boxed types","Add a startup check that all reflectively-invoked methods exist"],"tags":["reflection","nosuchmethod","classpath"],"backgroundTag":"resource-not-found","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}