apache/seatunnel · error · RuntimeException
method invoke failed
Error message
method invoke failed
What it means
This is the generic wrapper error from ReflectionUtils.invoke: any NoSuchMethodException, InvocationTargetException, or IllegalAccessException raised while reflectively invoking the method is rethrown as a RuntimeException with message 'method invoke failed'. The original cause (including the target method's own exception, in the InvocationTargetException case) is attached as the cause. Unlike error 180, the message itself does not say what went wrong, so the cause chain must be inspected.
Source
Thrown at seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/ReflectionUtils.java:105
}
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
- Log/inspect e.getCause(): for InvocationTargetException the real failure is e.getCause().getTargetException() from the invoked method
- If it is access-related, ensure the calling code has access or use setAccessible/opens flags in the module system
- Fix the root exception thrown inside the invoked method
- Guard the reflective call with a getDeclaredMethod presence check before invoking to get a clearer error
Example fix
// before
try { ReflectionUtils.invoke(obj, "run", new Class[0]); }
catch (Exception e) { log.error("invoke failed", e); }
// after
try { ReflectionUtils.invoke(obj, "run", new Class[0]); }
catch (Exception e) {
Throwable cause = e.getCause();
if (cause instanceof java.lang.reflect.InvocationTargetException) {
log.error("target method threw", cause.getCause());
}
} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check target method accessibility Method m = obj.getClass().getDeclaredMethod(methodName, argTypes); m.setAccessible(true); // throws early if access is denied
Type guard
boolean isInvokable(Object o, String name, Class<?>[] types) {
return ReflectionUtils.getDeclaredMethod(o.getClass(), name, types).isPresent();
} Try / catch
try {
return ReflectionUtils.invoke(obj, methodName, argTypes, args);
} catch (RuntimeException e) {
Throwable cause = e.getCause();
if (cause instanceof java.lang.reflect.InvocationTargetException
&& cause.getCause() != null) {
throw new RuntimeException("target method failed", cause.getCause());
}
throw e;
} Prevention
- Always log the full cause chain — the real error is inside the cause
- Use getDeclaredMethod presence checks for clearer diagnostics before invoking
- For JDK 9+ check module opens if IllegalAccessException occurs
- Avoid reflection on hot paths; prefer interfaces or adapters where possible
When it happens
Trigger: Any of: (a) missing method (see error 180), (b) the underlying method itself threw an exception, (c) setAccessible(true) was blocked and the method is not accessible from the caller.
Common situations: Debugging 'method invoke failed' with no detail — usually the target method threw (check the InvocationTargetException cause); Java module system or SecurityManager blocking reflective access to non-public methods; plugin exceptions surfacing wrapped in this error.
Related errors
- field set failed
- method invoke failed, no such method '%s' in '%s'
- Unable to instantiate the database history class " + config.
- Error scanning data from region.
- Hive metastore client factory ${clientFactoryClassName} retu
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/507bb49222e57626.
Report an issue: GitHub.