alibaba/canal · error · IllegalArgumentException
Invoke method failed: '{}' @ {}
Error message
Invoke method failed: '{}' @ {} What it means
Thrown by invokeMethod() when the reflectively-invoked method itself throws; the original target exception is attached as the cause (getTargetException). The error names which method on which class failed, but the real failure is the wrapped exception.
Source
Thrown at dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/DirectLogFetcher.java:127
+ e.getMessage(),
e);
}
return null;
}
return conn;
}
private static final Object invokeMethod(Object obj, Class<?> objClazz, String name) {
try {
Method method = objClazz.getMethod(name, (Class<?>[]) null);
return method.invoke(obj, (Object[]) null);
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException("No such method: \'" + name + "\' @ " + objClazz.getName(), e);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Cannot invoke method: \'" + name + "\' @ " + objClazz.getName(), e);
} catch (InvocationTargetException e) {
throw new IllegalArgumentException("Invoke method failed: \'" + name + "\' @ " + objClazz.getName(),
e.getTargetException());
}
}
private static final Object getDeclaredField(Object obj, Class<?> objClazz, String name) {
try {
Field field = objClazz.getDeclaredField(name);
field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException e) {
throw new IllegalArgumentException("No such field: \'" + name + "\' @ " + objClazz.getName(), e);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Cannot get field: \'" + name + "\' @ " + objClazz.getName(), e);
}
}
/**
* Connect MySQL master to fetch binlog.
View on GitHub (pinned to 87be50e876)
Solutions
- Inspect the cause (e.getCause() / getTargetException) of the IllegalArgumentException - the named method is a symptom, the cause is the real error.
- Ensure the Connection passed to open() is open and healthy before calling (validate with a SELECT 1).
- If the cause is network-related, retry open() on a fresh connection.
- Confirm the driver version's reflected method still behaves as the library assumes.
Example fix
// before
catch (IllegalArgumentException e) {
throw new RuntimeException(e);
}
// after - surface the real cause
catch (IllegalArgumentException e) {
Throwable real = e.getCause() != null ? e.getCause() : e;
logger.error("Reflected driver call failed: " + real, real);
throw new IOException("Driver internal call failed", real);
} Defensive patterns
Strategy: try-catch
Validate before calling
// Probe the connection is live so the reflected call won't throw internally
if (!conn.isValid(3)) {
throw new IOException("connection not valid; driver call would fail");
} Try / catch
try { fetcher.open(conn, file, pos, serverId, false); }
catch (IllegalArgumentException e) {
Throwable cause = e.getCause(); // the real getTargetException
logger.error("reflected driver call failed", cause);
throw new IOException("driver internal failure", cause);
} Prevention
- Always inspect the cause of the wrapped IllegalArgumentException - the named method is secondary.
- Pass only freshly-validated, open connections to open().
- Log the cause chain so the underlying driver exception is not hidden.
When it happens
Trigger: A reflected method on the mysql driver's Connection/IO object executed and threw an exception (e.g. the connection's underlying IO is closed, a network call failed, or an internal invariant was violated). invokeMethod re-throws as IllegalArgumentException with the target exception as cause.
Common situations: The mysql connection passed to DirectLogFetcher.open() was already closed or in a bad state; the driver threw an internal IOException/NPE during the reflected call; transient network reset between client and master.
Related errors
- No such method: '{}' @ {}
- No such field: '{}' @ {}
- Cannot invoke method: '{}' @ {}
- Cannot get field: '{}' @ {}
- Unable to unwrap {} to com.mysql.jdbc.ConnectionImpl
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/b478307a95202298.
Report an issue: GitHub.