{"record":{"id":"076e06a71d699707","repo":"apache/maven","slug":"non-existing-jdk-home-configuration-at-normal","errorCode":null,"errorMessage":"Non-existing JDK home configuration at \" + normal.toAbsolutePath()","messagePattern":"Non-existing JDK home configuration at \" \\+ normal\\.toAbsolutePath\\(\\)","errorType":"exception","errorClass":"MisconfiguredToolchainException","httpStatus":null,"severity":"error","filePath":"compat/maven-compat/src/main/java/org/apache/maven/toolchain/java/JavaToolchainFactory.java","lineNumber":95,"sourceCode":"            } else {\n                matcher = RequirementMatcherFactory.createExactMatcher(value);\n            }\n\n            jtc.addProvideToken(key, matcher);\n        }\n\n        // populate the configuration section\n        Xpp3Dom dom = (Xpp3Dom) model.getConfiguration();\n        Xpp3Dom javahome = dom != null ? dom.getChild(JavaToolchainImpl.KEY_JAVAHOME) : null;\n        if (javahome == null) {\n            throw new MisconfiguredToolchainException(\n                    \"Java toolchain without the \" + JavaToolchainImpl.KEY_JAVAHOME + \" configuration element.\");\n        }\n        Path normal = Paths.get(javahome.getValue()).normalize();\n        if (Files.exists(normal)) {\n            jtc.setJavaHome(Paths.get(javahome.getValue()).normalize().toString());\n        } else {\n            throw new MisconfiguredToolchainException(\n                    \"Non-existing JDK home configuration at \" + normal.toAbsolutePath());\n        }\n\n        ArtifactVersion javaVersion = model.getProvides().entrySet().stream()\n                .filter(entry -> \"version\".equals(entry.getKey()))\n                .map(Map.Entry::getValue)\n                .map(v -> new DefaultArtifactVersion((String) v))\n                .findAny()\n                .orElse(null);\n\n        jtc.setJavaVersion(javaVersion);\n        return jtc;\n    }\n\n    @Override\n    public ToolchainPrivate createDefaultToolchain() {\n        // not sure it's necessary to provide a default toolchain here.\n        // only version can be eventually supplied.","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/toolchain/java/JavaToolchainFactory.java#L77-L113","documentation":"After extracting jdkHome from the toolchain configuration, JavaToolchainFactory normalizes the path and checks Files.exists(normal). If the path does not exist on the machine running Maven, MisconfiguredToolchainException('Non-existing JDK home configuration at <absolutePath>') is thrown — the message shows the normalized absolute path that failed the existence check.","triggerScenarios":"toolchains.xml with a jdkHome pointing to a directory absent on the current machine: JDK uninstalled/upgraded to a different path, file shared across OSes (Windows path on Linux CI), typos, or unexpanded variables written literally into the XML.","commonSituations":"CI agents with different JDK install paths than developer machines; JDK version bump changing /usr/lib/jvm/... path; copying a colleague's toolchains.xml; using backslashes or a wrong drive letter on Windows.","solutions":["Check the absolute path in the message and correct jdkHome to an existing JDK directory on this machine","Use forward slashes on all platforms (C:/Program Files/Eclipse Adoptium/jdk-17) to avoid escaping issues","If agents differ, maintain per-machine toolchains.xml instead of sharing one file, or generate it in CI setup from the JAVA_HOME environment variable","Verify the directory is a real JDK home (contains bin/java) after fixing the path"],"exampleFix":"<!-- before: path does not exist on this machine -->\n<jdkHome>C:\\Program Files\\Java\\jdk-17</jdkHome>\n\n<!-- after -->\n<jdkHome>/usr/lib/jvm/temurin-17</jdkHome>","handlingStrategy":"validation","validationCode":"import java.nio.file.*;\n\nboolean jdkHomeExists(ToolchainModel model) {\n    Xpp3Dom config = (Xpp3Dom) model.getConfiguration();\n    Xpp3Dom home = config == null ? null : config.getChild(\"jdkHome\");\n    return home != null && Files.isDirectory(Paths.get(home.getValue()).normalize());\n}\n\nif (!jdkHomeExists(model)) {\n    throw new IllegalStateException(\"jdkHome in toolchains.xml does not exist on this machine\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    toolchainFactory.createToolchain(model, log);\n} catch (MisconfiguredToolchainException e) {\n    if (e.getMessage().startsWith(\"Non-existing JDK home\")) {\n        // message prints the normalized absolute path that failed\n        reportEnvError(\"Install the JDK at the printed path or update toolchains.xml\");\n    } else {\n        throw e;\n    }\n}","preventionTips":["Generate toolchains.xml per machine from JAVA_HOME during environment setup rather than sharing one file","Prefer forward slashes and absolute paths; verify with ls before committing to CI","Re-generate toolchains.xml whenever JDKs are upgraded or removed on build agents"],"tags":["maven","toolchains","jdk","filesystem","path"],"backgroundTag":"path-not-found","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}