{"record":{"id":"86b60de40a8de6ed","repo":"openjdk/jdk","slug":"error-opening-zip-file-or-jar-manifest-missing","errorCode":null,"errorMessage":"Error opening zip file or JAR manifest missing : %s\\n","messagePattern":"Error opening zip file or JAR manifest missing : (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/java.instrument/share/native/libinstrument/InvocationAdapter.c","lineNumber":179,"sourceCode":"    initerror = createNewJPLISAgent(vm, &agent, jarfile, JNI_FALSE);\n    if ( initerror == JPLIS_INIT_ERROR_NONE ) {\n        int             oldLen, newLen;\n        jarAttribute*   attributes;\n        char *          premainClass;\n        char *          bootClassPath;\n\n        /*\n         * Agent_OnLoad is specified to provide the agent options\n         * argument tail in modified UTF8. However for 1.5.0 this is\n         * actually in the platform encoding - see 5049313.\n         *\n         * Open zip/jar file and parse archive. If can't be opened or\n         * not a zip file return error. Also if Premain-Class attribute\n         * isn't present we return an error.\n         */\n        attributes = readAttributes(jarfile);\n        if (attributes == NULL) {\n            fprintf(stderr, \"Error opening zip file or JAR manifest missing : %s\\n\", jarfile);\n            free(jarfile);\n            if (options != NULL) free(options);\n            return JNI_ERR;\n        }\n\n        premainClass = getAttribute(attributes, \"Premain-Class\");\n        if (premainClass == NULL) {\n            fprintf(stderr, \"Failed to find Premain-Class manifest attribute in %s\\n\",\n                jarfile);\n            free(jarfile);\n            if (options != NULL) free(options);\n            freeAttributes(attributes);\n            return JNI_ERR;\n        }\n\n        /*\n         * The value of the Premain-Class attribute becomes the agent\n         * class name. The manifest is in UTF8 so need to convert to","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/src/java.instrument/share/native/libinstrument/InvocationAdapter.c#L161-L197","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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'"],"exampleFix":"# before\njava -javaagent:build/libs/myagent-boot.jar -jar app.jar  # boot repack broke manifest\n\n# after\njava -javaagent:build/libs/myagent.jar -jar app.jar       # plain jar with META-INF/MANIFEST.MF","handlingStrategy":"validation","validationCode":"// CI/build check before shipping a -javaagent invocation\ntry (ZipFile z = new ZipFile(\"agent.jar\")) {\n    if (z.getEntry(\"META-INF/MANIFEST.MF\") == null)\n        throw new IllegalStateException(\"agent jar has no manifest\");\n} catch (IOException e) {\n    throw new IllegalStateException(\"agent jar unreadable\", e);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["javaagent","instrumentation","jar","manifest","jvm-startup"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}