apache/maven · error · ComponentConfigurationException
Basic element '{}' must not contain child elements
Error message
Basic element '{}' must not contain child elements What it means
In the same composite-binding path, when the resolved value is not an instance of the set(...) parameter type, EnhancedCompositeBeanHelper falls back to converting the element's text via convertProperty - but only if the element has no child elements; a basic (scalar) element carrying nested XML is structurally invalid and throws ComponentConfigurationException "Basic element '<name>' must not contain child elements".
Source
Thrown at impl/maven-core/src/main/java/org/apache/maven/configuration/internal/EnhancedCompositeBeanHelper.java:98
// Find the default "set" method
MethodInfo setterInfo = findCachedMethod(beanType, "", null);
if (setterInfo == null) {
// Look for any method named "set" with one parameter
Map<String, MethodInfo> classMethodCache = METHOD_CACHE.computeIfAbsent(beanType, this::buildMethodCache);
setterInfo = classMethodCache.get("set");
}
if (setterInfo == null) {
throw new ComponentConfigurationException(configuration, "Cannot find default setter in " + beanType);
}
Object value = defaultValue;
TypeLiteral<?> paramType = TypeLiteral.get(setterInfo.parameterType);
if (!paramType.getRawType().isInstance(value)) {
if (configuration.getChildCount() > 0) {
throw new ComponentConfigurationException(
"Basic element '" + configuration.getName() + "' must not contain child elements");
}
value = convertProperty(beanType, paramType.getRawType(), paramType.getType(), configuration);
}
if (value != null) {
try {
if (listener != null) {
listener.notifyFieldChangeUsingSetter("", value, bean);
}
setterInfo.method.invoke(bean, value);
} catch (IllegalAccessException | InvocationTargetException | LinkageError e) {
throw new ComponentConfigurationException(configuration, "Cannot set default", e);
}
}
}
/**View on GitHub (pinned to e4093d4e12)
Solutions
- Flatten the element: give it text content (`<threadCount>4</threadCount>`) instead of children.
- Check the parameter's declared type for your plugin version and reshape the configuration to match.
- Pin or upgrade to the plugin version whose configuration style the existing XML follows.
Example fix
<!-- before --> <configuration> <threadCount><max>4</max></threadCount> </configuration> <!-- after --> <configuration> <threadCount>4</threadCount> </configuration>
Defensive patterns
Strategy: try-catch
Try / catch
try {
configurator.configureBean(request);
} catch (BeanConfigurationException e) {
if (e.getMessage() != null && e.getMessage().contains("must not contain child elements")) {
reportNestedScalarParameter(e); // flatten <param><child>x</child></param> to <param>x</param>
} else {
throw e;
}
} Prevention
- Match configuration shape to the parameter type: scalar types get text, not children.
- Re-check plugin docs after upgrades for parameters that changed from composite to simple types.
When it happens
Trigger: Configuration like `<threadCount><max>4</max></threadCount>` where the target set(...) accepts a scalar (e.g. String or int): the child elements make text conversion impossible.
Common situations: Upgrading a plugin whose parameter changed from a composite type to a simple type while old configuration kept nested XML; copy-pasting configuration between parameters of different shapes; stale examples in docs.
Related errors
- Unable to convert configuration to xml node
- Cannot find default setter in {}
- Cannot read metadata from '{}': {}
- Cannot serialize project model for interpolation.
- Cannot read project model from interpolating filter of seria
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/52b613e36dac28d3.
Report an issue: GitHub.