apache/seatunnel · warning · RuntimeException

Failed to invoke ${clazz.getName()}.${methodName}()

Error message

Failed to invoke ${clazz.getName()}.${methodName}()

What it means

RuntimeException thrown by invokeStaticNoArgIfExists when reflective invocation of a static no-arg method on a class (used by shutdownMySqlAbandonedConnectionCleanupThreadIfPresent to silence MySQL's cleanup thread) fails with a ReflectiveOperationException. The target class and method name are embedded in the message and the reflective exception is the cause.

Source

Thrown at seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/error/DefaultErrorSinkWriter.java:597

        if (invokeStaticNoArgIfExists(cleanupClass, "uncheckedShutdown")) {
            return;
        }
        invokeStaticNoArgIfExists(cleanupClass, "shutdown");
    }

    private boolean invokeStaticNoArgIfExists(Class<?> clazz, String methodName) {
        Method method;
        try {
            method = clazz.getDeclaredMethod(methodName);
        } catch (NoSuchMethodException e) {
            return false;
        }
        try {
            method.setAccessible(true);
            method.invoke(null);
            return true;
        } catch (ReflectiveOperationException e) {
            throw new RuntimeException(
                    "Failed to invoke " + clazz.getName() + "." + methodName + "()", e);
        }
    }

    private void waitForWorkerTermination(long timeoutMillis) {
        if (workerThread == null) {
            return;
        }
        if (!workerThread.isAlive()) {
            return;
        }
        try {
            workerThread.join(timeoutMillis);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            log.warn("Interrupted while waiting for error sink worker to close");
        }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Check the cause: if NoSuchMethodException-like, upgrade/downgrade the MySQL JDBC driver so the target method exists
  2. Verify the driver jar is complete and unshaded/correctly shaded
  3. Run without a restrictive SecurityManager or grant reflection permissions
  4. If only cleanup-related, this failure is mostly cosmetic - report/patch to tolerate missing methods
Defensive patterns

Strategy: try-catch

Validate before calling

try {
    Class.forName("com.mysql.cj.jdbc.AbandonedConnectionCleanupThread")
        .getMethod("shutdown");
} catch (ClassNotFoundException | NoSuchMethodException e) {
    LOG.warn("MySQL cleanup-thread shutdown not available in this driver version");
}

Try / catch

try {
    writer.close();
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Failed to invoke")) {
        LOG.warn("Non-critical reflection failure during shutdown", e);
        // treat as warning; cleanup-thread leak is benign
    }
}

Prevention

When it happens

Trigger: During error-sink worker shutdown, the writer looks up a static no-arg method (e.g. com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.shutdown) and either setAccessible or invoke fails: method not public/absent in the loaded MySQL driver version, security manager denial, or the class loader rejected access.

Common situations: MySQL connector version where AbandonedConnectionCleanupThread API changed (older drivers lack shutdown()); shaded/bundled MySQL driver with restricted access; running under a security policy blocking setAccessible.

Understand the failure class

Background: "is deprecated and will be removed" — deprecation warnings for old API names, keywords, and options, and how to migrate before the removal release — this error's family across 29 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/5e573e6359e4b4cc. Report an issue: GitHub.