{"record":{"id":"14e98994137e3b3b","repo":"apache/flink","slug":"the-program-s-entry-point-class-classname-thre","errorCode":null,"errorMessage":"The program's entry point class '{className}' threw an error during initialization.","messagePattern":"The program's entry point class '(.+?)' threw an error during initialization\\.","errorType":"exception","errorClass":"ProgramInvocationException","httpStatus":null,"severity":"critical","filePath":"flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java","lineNumber":491,"sourceCode":"            return null;\n        }\n    }\n\n    private static Class<?> loadMainClass(String className, ClassLoader cl)\n            throws ProgramInvocationException {\n        ClassLoader contextCl = null;\n        try {\n            contextCl = Thread.currentThread().getContextClassLoader();\n            Thread.currentThread().setContextClassLoader(cl);\n            return Class.forName(className, false, cl);\n        } catch (ClassNotFoundException e) {\n            throw new ProgramInvocationException(\n                    \"The program's entry point class '\"\n                            + className\n                            + \"' was not found in the jar file.\",\n                    e);\n        } catch (ExceptionInInitializerError e) {\n            throw new ProgramInvocationException(\n                    \"The program's entry point class '\"\n                            + className\n                            + \"' threw an error during initialization.\",\n                    e);\n        } catch (LinkageError e) {\n            throw new ProgramInvocationException(\n                    \"The program's entry point class '\"\n                            + className\n                            + \"' could not be loaded due to a linkage failure.\",\n                    e);\n        } catch (Throwable t) {\n            throw new ProgramInvocationException(\n                    \"The program's entry point class '\"\n                            + className\n                            + \"' caused an exception during initialization: \"\n                            + t.getMessage(),\n                    t);\n        } finally {","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java#L473-L509","documentation":"Thrown when the entry point class's static initializer fails (ExceptionInInitializerError) during Class.forName. This means the class was found but its static {} block or static field initialization threw an exception. The original error is chained as the cause.","triggerScenarios":"Loading a class whose static initializer performs an operation that fails: null dereference, failed config read, missing system property, static logger initialization failure, or a static field that calls a method which throws.","commonSituations":"Entry point class reads a system property or environment variable that is unset in deployment, static singleton initialization fails, or a static field references a resource that does not exist at class-load time.","solutions":["Examine the chained ExceptionInInitializerError cause to find the original exception in the static initializer.","Move risky initialization logic out of static blocks into instance or main-method scope.","Ensure all system properties, env vars, and resources the static initializer depends on are available.","Run the jar locally with the same classpath to reproduce the initialization failure with a full stack trace."],"exampleFix":"// before\npublic class JobMain {\n    private static final Config CFG = Config.load(\"/etc/job.conf\"); // throws if missing\n}\n\n// after\npublic class JobMain {\n    private static Config cfg;\n    public static void main(String[] args) {\n        cfg = Config.load(System.getProperty(\"job.config\", \"/etc/job.conf\"));\n    }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    PackagedProgram.newBuilder()\n        .setJarFile(jarFile)\n        .setEntryPointClassName(className)\n        .build();\n} catch (ProgramInvocationException e) {\n    if (e.getCause() instanceof ExceptionInInitializerError) {\n        Throwable initCause = e.getCause().getCause();\n        // log and address the static initializer failure\n    }\n    throw e;\n}","preventionTips":["Avoid heavy logic in static initializers of entry point classes.","Move resource/config loading into main() or instance init.","Test static initializers in isolation with the production classpath."],"tags":["packaged-program","class-loading","static-initializer","initialization"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}