{"record":{"id":"507bb49222e57626","repo":"apache/seatunnel","slug":"method-invoke-failed","errorCode":null,"errorMessage":"method invoke failed","messagePattern":"method invoke failed","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/ReflectionUtils.java","lineNumber":105,"sourceCode":"        }\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":87,"sourceCodeEnd":109,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/ReflectionUtils.java#L87-L109","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ntry { ReflectionUtils.invoke(obj, \"run\", new Class[0]); }\ncatch (Exception e) { log.error(\"invoke failed\", e); }\n// after\ntry { ReflectionUtils.invoke(obj, \"run\", new Class[0]); }\ncatch (Exception e) {\n  Throwable cause = e.getCause();\n  if (cause instanceof java.lang.reflect.InvocationTargetException) {\n    log.error(\"target method threw\", cause.getCause());\n  }\n}","handlingStrategy":"try-catch","validationCode":"// Pre-check target method accessibility\nMethod m = obj.getClass().getDeclaredMethod(methodName, argTypes);\nm.setAccessible(true); // throws early if access is denied","typeGuard":"boolean isInvokable(Object o, String name, Class<?>[] types) {\n  return ReflectionUtils.getDeclaredMethod(o.getClass(), name, types).isPresent();\n}","tryCatchPattern":"try {\n  return ReflectionUtils.invoke(obj, methodName, argTypes, args);\n} catch (RuntimeException e) {\n  Throwable cause = e.getCause();\n  if (cause instanceof java.lang.reflect.InvocationTargetException\n      && cause.getCause() != null) {\n    throw new RuntimeException(\"target method failed\", cause.getCause());\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["reflection","wrapped-exception","invocation-target"],"backgroundTag":"method-not-implemented","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"}