apache/maven · error · ComponentConfigurationException

Cannot evaluate expression '%s' for configuration entry '%s'

Error message

Cannot evaluate expression '%s' for configuration entry '%s'

What it means

Maven failed to interpolate a ${...} expression while configuring a plugin or component. EnhancedConfigurationConverter.fromExpression() delegates the raw string to the ExpressionEvaluator (normally PluginParameterExpressionEvaluator); any ExpressionEvaluationException is wrapped as a ComponentConfigurationException naming the offending expression and the configuration entry. An expression that resolves to null is silently accepted; only evaluation errors raise this.

Source

Thrown at impl/maven-core/src/main/java/org/apache/maven/configuration/internal/EnhancedConfigurationConverter.java:74

                }
            }
            if (null == result && configuration.getChildCount() == 0) {
                value = configuration.getAttribute("default-value");
                if (null != value && !value.isEmpty()) {
                    if (evaluator instanceof TypeAwareExpressionEvaluator typeAwareExpressionEvaluator) {
                        result = typeAwareExpressionEvaluator.evaluate(value, type);
                    } else {
                        result = evaluator.evaluate(value);
                    }
                }
            }
            failIfNotTypeCompatible(result, type, configuration);
            return result;
        } catch (final ExpressionEvaluationException e) {
            final String reason = String.format(
                    "Cannot evaluate expression '%s' for configuration entry '%s'", value, configuration.getName());

            throw new ComponentConfigurationException(configuration, reason, e);
        }
    }

    @Override
    public Object fromConfiguration(
            final ConverterLookup lookup,
            final PlexusConfiguration configuration,
            final Class<?> type,
            final Class<?> enclosingType,
            final ClassLoader loader,
            final ExpressionEvaluator evaluator,
            final ConfigurationListener listener)
            throws ComponentConfigurationException {
        final Object value = fromExpression(configuration, evaluator, type);
        if (type.isInstance(value)) {
            return value;
        }
        try {

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Run mvn -X to see the wrapped cause and identify which expression fails
  2. Define the property: add it to the pom <properties>, pass -Dkey=value, or put it in an active settings.xml profile
  3. If the value may legitimately be absent, guard by defining a default value for the property in the pom used as interpolation fallback
  4. Fail fast instead: add maven-enforcer requireProperty rules in the validate phase so missing properties are reported with clear messages

Example fix

<!-- before: property may be undefined at evaluation time -->
<configuration>
  <token>${api.token}</token>
</configuration>

<!-- after: give the property a default in the pom -->
<properties>
  <api.token>local-dev-token</api.token>
</properties>
Defensive patterns

Strategy: validation

Validate before calling

// Before running the build, assert every ${...} referenced in plugin config is defined
Set<String> defined = new HashSet<>();
request.getUserProperties().stringPropertyNames().forEach(defined::add);
request.getSystemProperties().stringPropertyNames().forEach(defined::add);
project.getModel().getProperties().stringPropertyNames().forEach(defined::add);
Matcher m = Pattern.compile("\\$\\{([^}]+)}").matcher(configXml);
while (m.find()) {
    String key = m.group(1);
    if (!key.startsWith("project.") && !key.startsWith("env.") && !defined.contains(key)) {
        throw new IllegalStateException("Undefined property referenced in plugin config: " + key);
    }
}

Try / catch

try {
    mojo.execute();
} catch (ComponentConfigurationException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Cannot evaluate expression")) {
        // interpolation failure: report which expression and fix the property, do not retry blindly
        log.error("Missing property for {}: {}", e.getMessage(), e.getCause().getMessage());
    }
}

Prevention

When it happens

Trigger: Any mojo configuration value (or default-value attribute) containing ${...} that the evaluator cannot resolve: an undefined property, an expression backed by a missing object, or malformed interpolation detected by the evaluator such as unbalanced '${'.

Common situations: Property defined only in a profile that is inactive in CI; ${env.VAR} missing in the build environment; typo'd property name; properties expected from an earlier plugin execution that did not run; migrating builds between environments with different settings.xml.

Related errors


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