{"record":{"id":"3d7f669a7adf51fd","repo":"apache/flink","slug":"could-not-invoke-the-main-method-arguments-are-no","errorCode":null,"errorMessage":"Could not invoke the main method, arguments are not matching.","messagePattern":"Could not invoke the main method, arguments are not matching\\.","errorType":"exception","errorClass":"ProgramInvocationException","httpStatus":null,"severity":"error","filePath":"flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java","lineNumber":361,"sourceCode":"                            + entryClass.getName()\n                            + \": \"\n                            + t.getMessage(),\n                    t);\n        }\n\n        if (!Modifier.isStatic(mainMethod.getModifiers())) {\n            throw new ProgramInvocationException(\n                    \"The class \" + entryClass.getName() + \" declares a non-static main method.\");\n        }\n        if (!Modifier.isPublic(mainMethod.getModifiers())) {\n            throw new ProgramInvocationException(\n                    \"The class \" + entryClass.getName() + \" declares a non-public main method.\");\n        }\n\n        try {\n            mainMethod.invoke(null, (Object) args);\n        } catch (IllegalArgumentException e) {\n            throw new ProgramInvocationException(\n                    \"Could not invoke the main method, arguments are not matching.\", e);\n        } catch (IllegalAccessException e) {\n            throw new ProgramInvocationException(\n                    \"Access to the main method was denied: \" + e.getMessage(), e);\n        } catch (InvocationTargetException e) {\n            Throwable exceptionInMethod = e.getTargetException();\n            if (exceptionInMethod instanceof Error) {\n                throw (Error) exceptionInMethod;\n            } else if (exceptionInMethod instanceof ProgramParametrizationException) {\n                throw (ProgramParametrizationException) exceptionInMethod;\n            } else if (exceptionInMethod instanceof ProgramInvocationException) {\n                throw (ProgramInvocationException) exceptionInMethod;\n            } else {\n                throw new ProgramInvocationException(\n                        \"The main method caused an error: \" + exceptionInMethod.getMessage(),\n                        exceptionInMethod);\n            }\n        } catch (Throwable t) {","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java#L343-L379","documentation":"Thrown by callMainMethod when Method.invoke raises IllegalArgumentException. Because the resolved method is main(String[]) and the argument passed is (Object) args (a String[]), an IllegalArgumentException here is unusual and typically indicates a JVM-level arity/signature mismatch rather than a user-correctable condition.","triggerScenarios":"Method.invoke(null, (Object) args) where args is a String[] but the JVM rejects the argument wrapping. Rare; can occur with synthetic/bridge main methods or bytecode-rewritten classes.","commonSituations":"The submitted class has been instrumented (agent, Lombok, Kotlin compiler quirks) producing a non-standard main signature; classpath shadowing with a different but compatible-named method.","solutions":["Inspect the attached IllegalArgumentException cause for the actual argument-type mismatch.","Confirm there is exactly one main(String[]) method (no synthetic/bridge duplicates) via javap on the class.","Remove bytecode-rewriting agents on the client JVM and resubmit.","If using Kotlin/Scala, ensure the compiled main is a true Java static main(String[])."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Inspect the method shape via reflection / javap before submitting\nMethod m = entryClass.getMethod(\"main\", String[].class);\nif (m.isBridge() || m.isSynthetic()) {\n    log.warn(\"main method is synthetic/bridge: {}\", m);\n}","typeGuard":null,"tryCatchPattern":"try {\n    packagedProgram.invokeInteractiveModeForExecution();\n} catch (ProgramInvocationException pie) {\n    if (pie.getMessage().contains(\"arguments are not matching\")) {\n        // run javap -v on the entry class to inspect main's true signature\n    }\n    throw pie;\n}","preventionTips":["Avoid bytecode-rewriting agents that change main's signature.","For Kotlin/Scala, ensure a genuine Java static main(String[]) is emitted.","Run javap on the compiled class to confirm main(String[]) is the only overload."],"tags":["packaged-program","invocation","reflection","argument-mismatch"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}