apache/seatunnel · error · NoSuchMethodException
method invoke failed, no such method '%s' in '%s'
Error message
method invoke failed, no such method '%s' in '%s'
What it means
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.
Source
Thrown at seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/ReflectionUtils.java:99
}
public static Object invoke(Object object, String methodName, Object... args) {
Class<?>[] argTypes = new Class[args.length];
for (int i = 0; i < args.length; i++) {
argTypes[i] = args[i].getClass();
}
return invoke(object, methodName, argTypes, args);
}
public static Object invoke(
Object object, String methodName, Class<?>[] argTypes, Object[] args) {
try {
Optional<Method> method = getDeclaredMethod(object.getClass(), methodName, argTypes);
if (method.isPresent()) {
method.get().setAccessible(true);
return method.get().invoke(object, args);
} else {
throw new NoSuchMethodException(
String.format(
"method invoke failed, no such method '%s' in '%s'",
methodName, object.getClass()));
}
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException("method invoke failed", e);
}
}
}
View on GitHub (pinned to cf67b549a7)
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
Example fix
// before
ReflectionUtils.invoke(obj, "getSplits", new Class[]{Integer.class}, 4);
// after
ReflectionUtils.invoke(obj, "getSplits", new Class[]{int.class}, 4); Defensive patterns
Strategy: type-guard
Validate before calling
java.util.Optional<java.lang.reflect.Method> m =
ReflectionUtils.getDeclaredMethod(obj.getClass(), "getSplits", new Class[]{int.class});
if (!m.isPresent()) { throw new IllegalStateException("missing method on " + obj.getClass()); } Type guard
boolean hasMethod(Object o, String name, Class<?>... types) {
try { o.getClass().getMethod(name, types); return true; }
catch (NoSuchMethodException e) { return false; }
} Try / catch
try {
return ReflectionUtils.invoke(obj, methodName, argTypes, args);
} catch (RuntimeException e) {
if (e.getCause() instanceof NoSuchMethodException) {
throw new IllegalStateException("Method " + methodName + " missing on " + obj.getClass(), e);
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Unable to load Hive metastore client factory ${clientFactory
- REFLECT_CLASS_OPERATION_FAILED
- CREATE_DRIVER_FAILED
- Failed to call factoryIdentifier method.
- Hadoop found on classpath but could not create config, proce
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/2402135dbf43fa9b.
Report an issue: GitHub.