{"record":{"id":"5b6cc934b4411bfc","repo":"apache/flink","slug":"the-program-s-entry-point-class-classname-was","errorCode":null,"errorMessage":"The program's entry point class '{className}' was not found in the jar file.","messagePattern":"The program's entry point class '(.+?)' was not found in the jar file\\.","errorType":"exception","errorClass":"ProgramInvocationException","httpStatus":null,"severity":"error","filePath":"flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java","lineNumber":485,"sourceCode":"            }\n\n            checkJarFile(jarFileUrl);\n\n            return jarFileUrl;\n        } else {\n            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(","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java#L467-L503","documentation":"Thrown when Class.forName(className, false, cl) raises a ClassNotFoundException while loading the entry point (main) class of a user jar. The class name was specified but is not present in the jar or any of the libraries on the provided ClassLoader. This is a ProgramInvocationException wrapping the original ClassNotFoundException.","triggerScenarios":"Calling PackagedProgram.newBuilder().setEntryPointClassName(className).build() or setJarFile + setEntryPointClassName where the named class does not exist in the jar or its embedded/attached libraries. Also triggered when a fat jar is missing shaded dependencies.","commonSituations":"Wrong main class name (typo, wrong package), jar built without bundling dependencies (thin jar), entry class in a dependency that was not packaged, or class name from manifest pointing to a relocated/shaded class.","solutions":["Verify the entry point class name matches a class inside the jar (inspect with 'jar tf your.jar | grep ClassName').","If using a thin jar, rebuild as a fat/uber jar so all dependencies are included.","Check that setEntryPointClassName uses the fully qualified name with correct package.","Ensure any required user-classpath libraries are added via setUserClassPaths."],"exampleFix":"// before\nPackagedProgram.newBuilder()\n    .setJarFile(jarFile)\n    .setEntryPointClassName(\"com.example.Main\")  // not in jar\n    .build();\n\n// after\nPackagedProgram.newBuilder()\n    .setJarFile(jarFile)\n    .setEntryPointClassName(\"com.example.JobMain\")  // correct FQN\n    .build();","handlingStrategy":"validation","validationCode":"try (JarFile jar = new JarFile(jarFile)) {\n    String entry = className.replace('.', '/') + \".class\";\n    if (jar.getJarEntry(entry) == null) {\n        throw new IllegalStateException(\"Class not found in jar: \" + className);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    PackagedProgram.newBuilder()\n        .setJarFile(jarFile)\n        .setEntryPointClassName(className)\n        .build();\n} catch (ProgramInvocationException e) {\n    if (e.getMessage().contains(\"was not found in the jar file\")) {\n        // class missing — fix class name or rebuild jar\n    }\n    throw e;\n}","preventionTips":["Verify the entry point class exists in the jar with 'jar tf' before deployment.","Use fully qualified class names matching the package structure.","Build fat jars to avoid missing transitive dependencies."],"tags":["packaged-program","class-loading","class-not-found","jar"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}