openjdk/jdk · error
AGENT_ERROR_BADJAR
AGENT_ERROR_BADJAR
Error message
Error opening zip file or JAR manifest missing: %s\n
What it means
Thrown on the attach path (Agent_OnAttach, error code AGENT_ERROR_BADJAR = 100): the native code could not open the given JAR as a zip or could not find/parse META-INF/MANIFEST.MF inside it, so readAttributes returned NULL. The attach fails and the attach API raises AgentInitializationException with return code 100.
Source
Thrown at src/java.instrument/share/native/libinstrument/InvocationAdapter.c:342
if (parseArgumentTail(args, &jarfile, &options) != 0) {
return JNI_ENOMEM;
}
jboolean print_warning = JVM_PrintWarningAtDynamicAgentLoad();
initerror = createNewJPLISAgent(vm, &agent, jarfile, print_warning);
if ( initerror == JPLIS_INIT_ERROR_NONE ) {
int oldLen, newLen;
jarAttribute* attributes;
char * agentClass;
char * bootClassPath;
jboolean success;
/*
* Open the JAR file and parse the manifest
*/
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 AGENT_ERROR_BADJAR;
}
agentClass = getAttribute(attributes, "Agent-Class");
if (agentClass == NULL) {
fprintf(stderr, "Failed to find Agent-Class manifest attribute from %s\n",
jarfile);
free(jarfile);
if (options != NULL) free(options);
freeAttributes(attributes);
return AGENT_ERROR_BADJAR;
}
/*
* Add the jarfile to the system class path
*/View on GitHub (pinned to 88dfb74bbe)
Solutions
- Verify the file is a valid zip: unzip -t agent.jar (or jar tf agent.jar)
- Confirm META-INF/MANIFEST.MF exists in the jar root and is parseable
- Check file permissions/reads on the target JVM's working user
- Rebuild or re-download the agent jar and re-attach
Example fix
# before: corrupted jar silently fails to attach
vm.loadAgent("/tmp/agent.jar");
# after: validate before attaching
try (ZipFile z = new ZipFile("/tmp/agent.jar")) {
if (z.getEntry("META-INF/MANIFEST.MF") == null) throw new IllegalStateException("manifest missing");
}
vm.loadAgent("/tmp/agent.jar"); Defensive patterns
Strategy: validation
Validate before calling
// before vm.loadAgent(path): confirm it is a readable zip with a manifest
Path p = Path.of(agentPath);
if (!Files.isRegularFile(p) || !Files.isReadable(p)) throw new IllegalArgumentException("agent jar missing/unreadable");
try (ZipFile z = new ZipFile(p.toFile())) {
if (z.getEntry("META-INF/MANIFEST.MF") == null) throw new IllegalArgumentException("manifest missing");
} Try / catch
try {
vm.loadAgent(agentPath, options);
} catch (AgentInitializationException e) {
if (e.returnValue() == 100) { /* BADJAR: re-fetch/rebuild jar, log and alert */ }
} Prevention
- Checksum-verify agent jars (sha256) after download before attaching
- Store agents in a stable directory owned by the JVM user
When it happens
Trigger: VirtualMachine.loadAgent called with a path that is not a zip/jar (corrupt download, truncated file, plain directory), a jar built without a manifest, or a file unreadable due to permissions.
Common situations: APM/profiling tools (JMC, async-profiler wrappers, APM agents) attaching to a jar corrupted in transfer; agent jar generated by a pipeline step that skipped the manifest; typo'd or relative path resolved against the wrong working directory.
Related errors
- Error opening zip file or JAR manifest missing : %s\n
- -javaagent: agent class not specified.\n
- AGENT_ERROR_NOTONCP
- AGENT_ERROR_STARTFAIL
- Unexpected error (%d) returned by AddToSystemClassLoaderSear
AI-assisted analysis of openjdk/jdk@88dfb74bbe (2026-08-14).
Data as JSON: /api/errors/edb3eee7dfb1996e.
Report an issue: GitHub.