{"record":{"id":"ac9330fad663c2d4","repo":"elastic/elasticsearch","slug":"70","errorCode":"70","errorMessage":"Expected to find [apm] module in [{apmModule}]! Installation is corrupt","messagePattern":"Expected to find \\[apm\\] module in \\[(.+?)\\]! Installation is corrupt","errorType":"exception","errorClass":"UserException","httpStatus":null,"severity":"critical","filePath":"distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/APMJvmOptions.java","lineNumber":362,"sourceCode":"            p.store(os, \" Automatically generated by Elasticsearch, do not edit!\");\n        }\n\n        return tmpFile;\n    }\n\n    /**\n     * The JVM argument that configure the APM agent needs to specify the agent jar path, so this method\n     * finds the jar by inspecting the filesystem.\n     * @return the agent jar file\n     * @throws IOException if a problem occurs reading the filesystem\n     */\n    @Nullable\n    static Path findAgentJar(String installDir) throws IOException, UserException {\n        final Path apmModule = Path.of(installDir).resolve(\"modules\").resolve(\"apm\");\n\n        if (Files.notExists(apmModule)) {\n            if (Build.current().isProductionRelease()) {\n                throw new UserException(\n                    ExitCodes.CODE_ERROR,\n                    \"Expected to find [apm] module in [\" + apmModule + \"]! Installation is corrupt\"\n                );\n            }\n            return null;\n        }\n\n        try (var apmStream = Files.list(apmModule)) {\n            final List<Path> paths = apmStream.filter(\n                path -> path.getFileName().toString().matches(\"elastic-apm-agent-java8-\\\\d+\\\\.\\\\d+\\\\.\\\\d+\\\\.jar\")\n            ).toList();\n\n            if (paths.size() > 1) {\n                throw new UserException(\n                    ExitCodes.CODE_ERROR,\n                    \"Found multiple [elastic-apm-agent] jars under [\" + apmModule + \"]! Installation is corrupt.\"\n                );\n            }","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/APMJvmOptions.java#L344-L380","documentation":"Thrown by APMJvmOptions.findAgentJar() when the modules/apm directory does not exist on a production release. The apm module ships the elastic-apm-agent jar that ES attaches as a javaagent; its absence on a production build means the installation is corrupt.","triggerScenarios":"Production release (Build.current().isProductionRelease() is true) and Path(installDir)/modules/apm does not exist. On non-production builds the method returns null instead.","commonSituations":"Someone deleted or never extracted modules/apm; a custom Docker image stripped the apm module; a repackaged distribution omitted it; partial extraction of the archive.","solutions":["Reinstall/re-extract Elasticsearch from the official archive so modules/apm is present.","If you intentionally strip the apm module, build a non-production release instead.","ls $ES_HOME/modules/apm — it must contain elastic-apm-agent-java8-*.jar."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"Path apmModule = Path.of(installDir).resolve(\"modules\").resolve(\"apm\");\nif (Build.current().isProductionRelease() && Files.notExists(apmModule)) {\n    throw new IllegalStateException(\"modules/apm missing — reinstall Elasticsearch.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the official distribution; do not prune modules/apm.","Add an image-build check: test -d \"$ES_HOME/modules/apm\".","Keep a checksum of the installed archive to detect tampering."],"tags":["apm","installation","corrupt","modules","filesystem"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}