{"record":{"id":"f64cd52f8bb882b0","repo":"alibaba/arthas","slug":"can-not-getresources-arthas-bin-zip-from-classload","errorCode":null,"errorMessage":"can not getResources arthas-bin.zip from classloader: ${classloader}","messagePattern":"can not getResources arthas-bin\\.zip from classloader: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"critical","filePath":"arthas-agent-attach/src/main/java/com/taobao/arthas/agent/attach/ArthasAgent.java","lineNumber":102,"sourceCode":"        } catch (Throwable e) {\n            // ignore\n        }\n\n        try {\n            if (instrumentation == null) {\n                instrumentation = ByteBuddyAgent.install();\n            }\n\n            // 检查 arthasHome\n            if (arthasHome == null || arthasHome.trim().isEmpty()) {\n                // 解压出 arthasHome\n                URL coreJarUrl = this.getClass().getClassLoader().getResource(\"arthas-bin.zip\");\n                if (coreJarUrl != null) {\n                    File tempArthasDir = createTempDir();\n                    ZipUtil.unpack(coreJarUrl.openStream(), tempArthasDir);\n                    arthasHome = tempArthasDir.getAbsolutePath();\n                } else {\n                    throw new IllegalArgumentException(\"can not getResources arthas-bin.zip from classloader: \"\n                            + this.getClass().getClassLoader());\n                }\n            }\n\n            // find arthas-core.jar\n            File arthasCoreJarFile = new File(arthasHome, ARTHAS_CORE_JAR);\n            if (!arthasCoreJarFile.exists()) {\n                throw new IllegalStateException(\"can not find arthas-core.jar under arthasHome: \" + arthasHome);\n            }\n            AttachArthasClassloader arthasClassLoader = new AttachArthasClassloader(\n                    new URL[] { arthasCoreJarFile.toURI().toURL() });\n\n            /**\n             * <pre>\n             * ArthasBootstrap bootstrap = ArthasBootstrap.getInstance(inst);\n             * </pre>\n             */\n            Class<?> bootstrapClass = arthasClassLoader.loadClass(ARTHAS_BOOTSTRAP);","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/arthas-agent-attach/src/main/java/com/taobao/arthas/agent/attach/ArthasAgent.java#L84-L120","documentation":"Thrown by ArthasAgent.attach when arthasHome is not supplied and the current classloader cannot locate the bundled arthas-bin.zip resource. arthas-bin.zip is the packaged arthas distribution embedded in the arthas-agent-attach jar; if it is absent the agent cannot extract a working arthasHome.","triggerScenarios":"Using a repackaged/shaded arthas-agent-attach jar from which arthas-bin.zip was excluded; a custom/parent classloader that does not expose embedded resources; running the agent classes from an exploded layout that lost the zip.","commonSituations":"Maven shade/assembly plugin filtered out the zip; a dependency resolver stripped large binary resources; embedding only the .class files without the resource.","solutions":["Use the official, unmodified arthas-agent-attach jar that contains arthas-bin.zip.","Pass an explicit arthasHome (a directory with arthas-core.jar) so the resource lookup is skipped.","Fix the shade/assembly config to include arthas-bin.zip under resources."],"exampleFix":"// before\nArthasAgent.attach(configWithoutArthasHome);\n// -> can not getResources arthas-bin.zip from classloader\n\n// after\n// point config arthasHome to a full arthas install dir\nconfig.put(\"arthasHome\", \"/opt/arthas\");\nArthasAgent.attach(config);","handlingStrategy":"validation","validationCode":"java.net.URL zip = agentCL.getResource(\"arthas-bin.zip\");\nif (zip == null && (arthasHome == null || arthasHome.trim().isEmpty())) {\n  throw new IllegalStateException(\"arthas-bin.zip missing; supply arthasHome\");\n}","typeGuard":null,"tryCatchPattern":"try { agent.attach(config); }\ncatch (IllegalArgumentException e) { if (e.getMessage().contains(\"arthas-bin.zip\")) { config.put(\"arthasHome\", installDir); agent.attach(config); } else throw e; }","preventionTips":["Use the official unmodified arthas-agent-attach jar.","Always supply arthasHome in embedded usage.","Keep arthas-bin.zip in shade/assembly resources."],"tags":["arthas","agent-attach","classpath","packaging"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}