apache/flink · error · ProgramInvocationException
Neither a '{MANIFEST_ATTRIBUTE_MAIN_CLASS}', nor a '{MANIFES
Error message
Neither a '{MANIFEST_ATTRIBUTE_MAIN_CLASS}', nor a '{MANIFEST_ATTRIBUTE_ASSEMBLER_CLASS}' entry was found in the jar file. What it means
Thrown by getEntryPointClassNameFromJar when the manifest is present but contains neither Flink's 'program-class' attribute nor the standard Java 'Main-Class' attribute. The manifest exists but does not declare an entry point, so Flink cannot determine the driver class.
Source
Thrown at flink-clients/src/main/java/org/apache/flink/client/program/PackagedProgram.java:441
"No manifest found in jar file '"
+ jarFile.getPath()
+ "'. The manifest is need to point to the program's main class.");
}
Attributes attributes = manifest.getMainAttributes();
// check for a "program-class" entry first
className = attributes.getValue(PackagedProgram.MANIFEST_ATTRIBUTE_ASSEMBLER_CLASS);
if (className != null) {
return className;
}
// check for a main class
className = attributes.getValue(PackagedProgram.MANIFEST_ATTRIBUTE_MAIN_CLASS);
if (className != null) {
return className;
} else {
throw new ProgramInvocationException(
"Neither a '"
+ MANIFEST_ATTRIBUTE_MAIN_CLASS
+ "', nor a '"
+ MANIFEST_ATTRIBUTE_ASSEMBLER_CLASS
+ "' entry was found in the jar file.");
}
} finally {
try {
jar.close();
} catch (Throwable t) {
throw new ProgramInvocationException(
"Could not close the JAR file: " + t.getMessage(), t);
}
}
}
@Nullable
private static URL loadJarFile(File jar) throws ProgramInvocationException {View on GitHub (pinned to 2f3c205e92)
Solutions
- Specify the entry class explicitly with --class <fully.qualified.MainClass>.
- Rebuild the jar adding 'Main-Class' to the manifest (Maven shade/jar plugin 'mainClass'), or Flink's 'program-class' attribute.
- Verify the manifest attribute name matches exactly 'Main-Class' or 'program-class' (case-sensitive).
Example fix
# before: jar manifest has neither Main-Class nor program-class flink run /opt/jobs/myjob.jar # after (runtime): pass the class flink run -c com.example.MyJob /opt/jobs/myjob.jar # after (build, pom.xml) # <plugin><artifactId>maven-shade-plugin</artifactId> # <configuration><transformers> # <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> # <mainClass>com.example.MyJob</mainClass> # </transformer> # </transformers></configuration></plugin>
Defensive patterns
Strategy: validation
Validate before calling
try (JarFile jf = new JarFile(jarFile)) {
Manifest m = jf.getManifest();
if (m == null
|| (m.getMainAttributes().getValue("Main-Class") == null
&& m.getMainAttributes().getValue("program-class") == null)) {
// jar cannot self-describe its entry point — caller must pass --class
throw new IllegalArgumentException("Jar has no Main-Class/program-class attribute");
}
} Try / catch
try {
PackagedProgram.newBuilder().setJarFile(jarFile).build();
} catch (ProgramInvocationException pie) {
if (pie.getMessage().contains("Neither a")) {
// rebuild with Main-Class, or pass .setEntryPointClassName()
}
throw pie;
} Prevention
- Set 'Main-Class' (or Flink 'program-class') in the manifest at build time.
- Pass --class explicitly for jars without a self-describing manifest.
- Check attribute names are exactly 'Main-Class' / 'program-class' (case-sensitive).
When it happens
Trigger: The jar's META-INF/MANIFEST.MF exists but has no 'program-class' and no 'Main-Class' header. Checked in order: program-class first, then Main-Class.
Common situations: A library jar that has a manifest (e.g. for vendor metadata) but was never configured as an executable jar; a manifest whose main-class was set under a different/custom attribute name.
Related errors
- No manifest found in jar file '{jarFile.getPath()}'. The man
- The given program class does not have a main(String[]) metho
- The Manifest in the jar file could not be accessed '{jarFile
- Error while getting the program description
- Invalid file path '{jarFile.getPath()}'
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/76096a76da401000.
Report an issue: GitHub.