{"record":{"id":"e9d66419dcd9daa2","repo":"apache/flink","slug":"an-error-occurred-while-invoking-the-program-s-mai","errorCode":null,"errorMessage":"An error occurred while invoking the program's main method: {t.getMessage()}","messagePattern":"An error occurred while invoking the program's main method: (.+?)","errorType":"exception","errorClass":"ProgramInvocationException","httpStatus":null,"severity":"error","filePath":"flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java","lineNumber":380,"sourceCode":"                    \"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) {\n            throw new ProgramInvocationException(\n                    \"An error occurred while invoking the program's main method: \" + t.getMessage(),\n                    t);\n        }\n    }\n\n    private static String getEntryPointClassNameFromJar(URL jarFile)\n            throws ProgramInvocationException {\n        JarFile jar;\n        Manifest manifest;\n        String className;\n\n        // Open jar file\n        try {\n            jar = new JarFile(new File(jarFile.toURI()));\n        } catch (URISyntaxException use) {\n            throw new ProgramInvocationException(\n                    \"Invalid file path '\" + jarFile.getPath() + \"'\", use);\n        } catch (IOException ioex) {","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java#L362-L398","documentation":"Thrown by callMainMethod in the outer 'catch (Throwable t)' — a catch-all for any Throwable that is not IllegalArgumentException, IllegalAccessException, or InvocationTargetException. This catches Throwable-level errors raised during the Method.invoke call itself (not inside main), such as LinkageError, StackOverflowError, or ThreadDeath.","triggerScenarios":"Method.invoke raises a Throwable that bypasses the three specific exception catches — typically a LinkageError, ClassCircularityError, or other JVM/bytecode-level error.","commonSituations":"Corrupted or incompatible bytecode in the user jar; dependency version conflicts producing LinkageError/IncompatibleClassChangeError at invoke time; OutOfMemoryError during class initialization.","solutions":["Inspect the appended ': <message>' and the attached Throwable cause for the JVM-level error class.","Resolve dependency conflicts (use Flink's dependency-convergence check; shade conflicting transitive deps in the user jar).","Rebuild the user jar from a clean state to eliminate bytecode corruption.","If OutOfMemoryError/StackOverflowError, tune JVM heap/stack in flink-conf.yaml."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: check dependency convergence with Maven Enforcer before building the jar\n// <plugin><artifactId>maven-enforcer-plugin</artifactId>\n//   <executions><execution><id>enforce</id><goals><goal>enforce</goal></goals>\n//     <configuration><rules><dependencyConvergence/></rules></configuration>\n//   </execution></executions></plugin>","typeGuard":null,"tryCatchPattern":"try {\n    packagedProgram.invokeInteractiveModeForExecution();\n} catch (ProgramInvocationException pie) {\n    Throwable t = pie.getCause();\n    if (t instanceof LinkageError) {\n        // dependency conflict — inspect classpath, shade the conflicting lib\n    }\n    throw pie;\n}","preventionTips":["Run maven-enforcer dependencyConvergence in the user jar build to catch version conflicts early.","Shade/transitive-reduce conflicting dependencies in the user jar.","Rebuild from clean to eliminate stale/corrupt bytecode."],"tags":["packaged-program","invocation","linkage-error","bytecode"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}