apache/maven · error · ToolchainFactoryException

Provides token '" + key + "' doesn't have any value configur

Error message

Provides token '" + key + "' doesn't have any value configured.

What it means

DefaultJavaToolchainFactory.createToolchain builds matchers from the <provides> section of a toolchain declaration in toolchains.xml. Every provides token must map to a non-null string value; an entry with a null value throws ToolchainFactoryException. This is a declarative configuration error caught when the toolchain is built, before any JDK is used.

Source

Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultJavaToolchainFactory.java:71

    private static final Logger LOGGER = LoggerFactory.getLogger(DefaultJavaToolchainFactory.class);

    final VersionParser versionParser;

    @Inject
    public DefaultJavaToolchainFactory(VersionParser versionParser) {
        this.versionParser = versionParser;
    }

    @Nonnull
    @Override
    public JavaToolchain createToolchain(@Nonnull ToolchainModel model) {
        // populate the provides section
        Map<String, Predicate<String>> matchers = model.getProvides().entrySet().stream()
                .collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, entry -> {
                    String key = entry.getKey();
                    String value = entry.getValue();
                    if (value == null) {
                        throw new ToolchainFactoryException(
                                "Provides token '" + key + "' doesn't have any value configured.");
                    }
                    return "version".equals(key) ? new VersionMatcher(versionParser, value) : new ExactMatcher(value);
                }));

        // compute and normalize the java home
        XmlNode dom = model.getConfiguration();
        XmlNode javahome = dom != null ? dom.child(KEY_JAVAHOME) : null;
        if (javahome == null || javahome.value() == null) {
            throw new ToolchainFactoryException(
                    "Java toolchain without the " + KEY_JAVAHOME + " configuration element.");
        }
        Path normal = Paths.get(javahome.value()).normalize();
        if (!Files.exists(normal)) {
            throw new ToolchainFactoryException("Non-existing JDK home configuration at " + normal.toAbsolutePath());
        }
        String javaHome = normal.toString();

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Give every <provides> token a text value, e.g. <provides><version>17</version><vendor>temurin</vendor></provides>
  2. Check for self-closing tags (<token/>) and stray attribute-style values in toolchains.xml and convert them to element text
  3. If the token is not needed, delete it entirely rather than leaving it empty

Example fix

<!-- before -->
<toolchain>
  <type>jdk</type>
  <provides>
    <version/>
  </provides>
  <configuration><jdkHome>/usr/lib/jvm/java-17</jdkHome></configuration>
</toolchain>

<!-- after -->
<toolchain>
  <type>jdk</type>
  <provides>
    <version>17</version>
  </provides>
  <configuration><jdkHome>/usr/lib/jvm/java-17</jdkHome></configuration>
</toolchain>
Defensive patterns

Strategy: validation

Validate before calling

for (Map.Entry<String, String> e : model.getProvides().entrySet()) {
    if (e.getValue() == null || e.getValue().isBlank()) {
        throw new IllegalArgumentException('Toolchain provides token without value: ' + e.getKey());
    }
}

Prevention

When it happens

Trigger: A ~/.m2/toolchains.xml <toolchain> block where <provides> contains an element with empty content that the model parses as null, e.g. <provides><version/></provides> or a token defined only as an attribute placeholder without a body.

Common situations: Hand-edited toolchains.xml with self-closed or empty provides tokens; templates that inject provides values from environment variables that resolve to nothing; XML with the value accidentally placed in an attribute instead of element text.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/4625f24e57758633. Report an issue: GitHub.