{"record":{"id":"2352b3169b37a39a","repo":"pinpoint-apm/pinpoint","slug":"failed-to-close-jarfile","errorCode":null,"errorMessage":"Failed to close JarFile:","messagePattern":"Failed to close JarFile:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"agent-module/bootstraps/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/PinpointBootStrap.java","lineNumber":160,"sourceCode":"            logger.info(\"agentParameter:\" + agentArgs);\n        }\n        return agentArgsMap;\n    }\n\n    private void appendToBootstrapClassLoader(Instrumentation instrumentation, BootDir bootDir) {\n        List<JarFile> jarFiles = bootDir.openJarFiles();\n        try {\n            for (JarFile jarFile : jarFiles) {\n                Path path = FileUtils.subpathAfterLast(Paths.get(jarFile.getName()), 2);\n                logger.info(\"appendToBootstrapClassLoader:\" + path);\n                instrumentation.appendToBootstrapClassLoaderSearch(jarFile);\n            }\n        } finally {\n            for (JarFile jarFile : jarFiles) {\n                try {\n                    jarFile.close();\n                } catch (Exception e) {\n                    logger.warn(\"Failed to close JarFile:\" + jarFile.getName(), e);\n                }\n            }\n        }\n    }\n\n\n    private static void logPinpointAgentLoadFail() {\n        final String errorLog =\n                \"*****************************************************************************\\n\" +\n                        \"* Pinpoint Agent load failure\\n\" +\n                        \"*****************************************************************************\";\n        System.err.println(errorLog);\n    }\n\n\n}\n","sourceCodeStart":142,"sourceCodeEnd":177,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/bootstraps/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/PinpointBootStrap.java#L142-L177","documentation":"After appending boot jars to the bootstrap class loader, the code closes each opened JarFile in a finally block; if closing one fails the exception is logged as this warning. Instrumentation continues; this indicates a leaked/locked jar handle or filesystem oddity, not a failed load.","triggerScenarios":"JarFile.close() throws due to OS-level file locking (Windows), an already-closed handle, or the jar file being deleted/moved while the JVM holds it open.","commonSituations":"Running on Windows with antivirus or another process holding the jar; agent directory swapped while the JVM is starting; duplicated jar handles opened during appendToBootstrapClassLoader.","solutions":["Generally safe to ignore — the agent proceeds; verify the agent started normally afterwards","On Windows, exclude the agent directory from antivirus scanning","Avoid replacing/deleting agent jars while the JVM is running","If it recurs, check for duplicate boot jar entries in the agent's boot directory"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat this as non-fatal; confirm 'pinpoint agent started normally' appears afterwards","On Windows, exclude the agent dir from antivirus/backup locks","Never mutate agent jars while the JVM is running"],"tags":["java","io","jarfile","resource-cleanup"],"backgroundTag":"file-open-failed","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}