{"record":{"id":"e06261c41a5c274a","repo":"apache/maven","slug":"non-existing-jdk-home-configuration-at","errorCode":null,"errorMessage":"Non-existing JDK home configuration at ","messagePattern":"Non-existing JDK home configuration at ","errorType":"validation","errorClass":"ToolchainFactoryException","httpStatus":null,"severity":"error","filePath":"impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultJavaToolchainFactory.java","lineNumber":86,"sourceCode":"                    String key = entry.getKey();\n                    String value = entry.getValue();\n                    if (value == null) {\n                        throw new ToolchainFactoryException(\n                                \"Provides token '\" + key + \"' doesn't have any value configured.\");\n                    }\n                    return \"version\".equals(key) ? new VersionMatcher(versionParser, value) : new ExactMatcher(value);\n                }));\n\n        // compute and normalize the java home\n        XmlNode dom = model.getConfiguration();\n        XmlNode javahome = dom != null ? dom.child(KEY_JAVAHOME) : null;\n        if (javahome == null || javahome.value() == null) {\n            throw new ToolchainFactoryException(\n                    \"Java toolchain without the \" + KEY_JAVAHOME + \" configuration element.\");\n        }\n        Path normal = Paths.get(javahome.value()).normalize();\n        if (!Files.exists(normal)) {\n            throw new ToolchainFactoryException(\"Non-existing JDK home configuration at \" + normal.toAbsolutePath());\n        }\n        String javaHome = normal.toString();\n\n        Version javaVersion = model.getProvides().entrySet().stream()\n                .filter(entry -> \"version\".equals(entry.getKey()))\n                .map(Map.Entry::getValue)\n                .map(versionParser::parseVersion)\n                .findAny()\n                .orElse(null);\n\n        return new DefaultJavaToolchain(model, javaHome, javaVersion, matchers);\n    }\n\n    @Nonnull\n    @Override\n    public Optional<Toolchain> createDefaultToolchain() {\n        return Optional.empty();\n    }","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultJavaToolchainFactory.java#L68-L104","documentation":"DefaultJavaToolchainFactory validates that the path given in <jdkHome> exists on the filesystem before accepting the toolchain. Paths.get(value).normalize() is checked with Files.exists; a path that does not resolve to an existing directory throws ToolchainFactoryException with the absolute path in the message. Note that existence is checked from the machine running Maven, not the machine that wrote the file.","triggerScenarios":"toolchains.xml pointing to a JDK location that is absent on the current machine: /usr/lib/jvm/java-17 on a host where the JDK was upgraded/removed, or a developer-specific path (C:\\Users\\alice\\...) used by another developer or CI runner.","commonSituations":"Team-committed or copied toolchains.xml with machine-specific paths; macOS JDK version bump invalidating /Library/Java/JavaVirtualMachines/...; container images where the JDK lives at a different prefix; symlinks removed after OS updates; typo in the path.","solutions":["Correct jdkHome to an existing JDK directory on this machine (verify with ls /path)","Use environment-relative setup: JAVA_HOME-based toolchain discovery or keep per-machine toolchains.xml in ~/.m2 instead of committing it","On CI, install the expected JDK at the documented path or generate toolchains.xml in the pipeline"],"exampleFix":"<!-- before -->\n<jdkHome>/usr/lib/jvm/java-17-openjdk</jdkHome> <!-- removed by upgrade -->\n\n<!-- after -->\n<jdkHome>/usr/lib/jvm/java-21-openjdk</jdkHome>","handlingStrategy":"validation","validationCode":"String home = jdkHome.value();\nif (!Files.isDirectory(Paths.get(home))) {\n    throw new IllegalArgumentException('jdkHome does not exist on this machine: ' + home);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep toolchains.xml per-machine (~/.m2) instead of committing absolute paths","In CI, install JDKs at fixed paths and generate toolchains.xml in the pipeline","Re-check paths after JDK upgrades or OS updates"],"tags":["maven","toolchains","filesystem","jdk","path"],"backgroundTag":"toolchain-misconfiguration","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}