apache/maven · error · ComponentConfigurationException

Unable to convert configuration to xml node

Error message

Unable to convert configuration to xml node

What it means

When a mojo/component parameter is typed org.apache.maven.api.xml.XmlNode, DefaultBeanConfigurator's XmlConverter converts the Plexus configuration subtree to an XML node, evaluating every text value through the expression evaluator first; if evaluation throws ExpressionEvaluationException (in Maven this wraps a BeanConfigurationException from the value preprocessor), the binding fails with ComponentConfigurationException 'Unable to convert configuration to xml node'. The culprit is interpolation inside that XML-valued parameter.

Source

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

        public boolean canConvert(Class<?> type) {
            return XmlNode.class.equals(type);
        }

        @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 {

            try {
                return toXml(configuration, evaluator);
            } catch (ExpressionEvaluationException e) {
                throw new ComponentConfigurationException("Unable to convert configuration to xml node", e);
            }
        }

        XmlNode toXml(PlexusConfiguration config, ExpressionEvaluator evaluator) throws ExpressionEvaluationException {
            List<XmlNode> children = new ArrayList<>();
            for (PlexusConfiguration c : config.getChildren()) {
                children.add(toXml(c, evaluator));
            }
            String name = config.getName();
            Object value = evaluator.evaluate(config.getValue());
            return XmlNode.newInstance(name, value != null ? value.toString() : null, null, children, null);
        }
    }

    static class PathConverter extends AbstractBasicConverter {
        @Override
        public boolean canConvert(Class<?> type) {
            return Path.class.equals(type);

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Locate the ${...} token inside the failing plugin's XML-valued parameter and fix or remove it.
  2. Pass dynamic values through simple string parameters and reference them, keeping literal XML static.
  3. Check plugin version compatibility - older plugins may use expressions the current evaluator refuses.
  4. If the expression is intentional, verify the referenced property/object exists at configuration time (set it via -D, settings, or profile).

Example fix

<!-- before: expression inside an XmlNode-valued parameter the evaluator cannot resolve -->
<config>
  <ruleset>${build.ruleset.dir}/rules.xml</ruleset>
</config>

<!-- after: literal value (or bind via a plain String parameter) -->
<config>
  <ruleset>src/main/resources/rules.xml</ruleset>
</config>
Defensive patterns

Strategy: try-catch

Try / catch

try {
    configurator.configureBean(request); // XmlConverter failures surface here
} catch (BeanConfigurationException e) {
    if (e.getMessage() != null && e.getMessage().contains("Unable to convert configuration to xml node")) {
        reportBadExpressionInParameter(request, e); // point at the ${...} inside the XML param
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: A plugin configuration block bound to an XmlNode parameter whose text contains ${...} that the preprocessor fails on - e.g. expressions referencing objects unavailable at configuration time, or nested/malformed expression syntax the evaluator rejects.

Common situations: Plugins with XML-blob parameters (inline rule/config fragments) embedding property placeholders; upgrades changing which expressions the evaluator accepts; builds where a property referenced in XML config is consumed before the context providing it exists.

Related errors


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