openjdk/jdk · critical
Error opening zip file or JAR manifest missing : %s\n
Error message
Error opening zip file or JAR manifest missing : %s\n
What it means
The -javaagent jar was opened/parsed and readAttributes() returned NULL: either the file is not readable/is not a zip/jar, or its META-INF/MANIFEST.MF is missing/unparseable. The launcher prints the jar path, frees memory, and returns JNI_ERR — the JVM will not start with this agent.
Source
Thrown at src/java.instrument/share/native/libinstrument/InvocationAdapter.c:179
initerror = createNewJPLISAgent(vm, &agent, jarfile, JNI_FALSE);
if ( initerror == JPLIS_INIT_ERROR_NONE ) {
int oldLen, newLen;
jarAttribute* attributes;
char * premainClass;
char * bootClassPath;
/*
* Agent_OnLoad is specified to provide the agent options
* argument tail in modified UTF8. However for 1.5.0 this is
* actually in the platform encoding - see 5049313.
*
* Open zip/jar file and parse archive. If can't be opened or
* not a zip file return error. Also if Premain-Class attribute
* isn't present we return an error.
*/
attributes = readAttributes(jarfile);
if (attributes == NULL) {
fprintf(stderr, "Error opening zip file or JAR manifest missing : %s\n", jarfile);
free(jarfile);
if (options != NULL) free(options);
return JNI_ERR;
}
premainClass = getAttribute(attributes, "Premain-Class");
if (premainClass == NULL) {
fprintf(stderr, "Failed to find Premain-Class manifest attribute in %s\n",
jarfile);
free(jarfile);
if (options != NULL) free(options);
freeAttributes(attributes);
return JNI_ERR;
}
/*
* The value of the Premain-Class attribute becomes the agent
* class name. The manifest is in UTF8 so need to convert toView on GitHub (pinned to 88dfb74bbe)
Solutions
- Verify the file: 'unzip -l agent.jar' must list META-INF/MANIFEST.MF; if not, rebuild with the manifest included
- Check the path in the -javaagent option is absolute or resolvable from the JVM's cwd, and correctly quoted
- Rebuild the agent jar so it does not pass through shade/bootJar/spring-boot repackage — attach the original thin jar
- Re-download/copy the agent jar if it may be truncated, and confirm it opens with 'jar tf'
Example fix
# before java -javaagent:build/libs/myagent-boot.jar -jar app.jar # boot repack broke manifest # after java -javaagent:build/libs/myagent.jar -jar app.jar # plain jar with META-INF/MANIFEST.MF
Defensive patterns
Strategy: validation
Validate before calling
// CI/build check before shipping a -javaagent invocation
try (ZipFile z = new ZipFile("agent.jar")) {
if (z.getEntry("META-INF/MANIFEST.MF") == null)
throw new IllegalStateException("agent jar has no manifest");
} catch (IOException e) {
throw new IllegalStateException("agent jar unreadable", e);
} Prevention
- Never let shade/boot repackage steps touch the agent jar
- Smoke-test 'java -javaagent:... -version' in CI to catch bad jars early
- Verify jar integrity ('jar tf') after any transfer step
When it happens
Trigger: java -javaagent:agent.jar where agent.jar does not exist, is a plain (non-zip) file, is corrupt/truncated, or was built without a manifest (jar cfe omitted / Maven Shade misconfiguration dropping META-INF/MANIFEST.MF). Also paths with wrong case or Windows backslashes mishandled in the option string.
Common situations: CI builds stripping manifests via repackaging; agents downloaded incompletely; quoting problems in shell/Gradle arguments; using a class-directory instead of a jar; Spring Boot executable-jar repackaging applied to the agent jar destroying its layout.
Related errors
- Failed to find Premain-Class manifest attribute in %s\n
- -javaagent: Premain-Class value is too big\n
- -javaagent: memory allocation failure.\n
- -javaagent: memory allocation failed\n
- java.lang.instrument/-javaagent: cannot create native agent.
AI-assisted analysis of openjdk/jdk@88dfb74bbe (2026-08-14).
Data as JSON: /api/errors/86b60de40a8de6ed.
Report an issue: GitHub.