apache/maven · error · ComponentConfigurationException
Cannot find '{}' in {}
Error message
Cannot find '{}' in {} What it means
Plexus bean configuration could not map a configuration element to any writable property of the target class. EnhancedCompositeBeanHelper.setProperty() looks for a setter/adder method ('setFoo'/'addFoo' for element 'foo') and then for a declared field named 'foo'; the error is thrown only when BOTH lookups fail (methodInfo == null && field == null), i.e. the bean exposes no such property at all.
Source
Thrown at impl/maven-core/src/main/java/org/apache/maven/configuration/internal/EnhancedCompositeBeanHelper.java:160
Field field = findCachedField(beanType, propertyName);
if (field != null) {
try {
Object value = convertPropertyForField(beanType, field, valueType, configuration);
if (value != null) {
if (listener != null) {
listener.notifyFieldChangeUsingReflection(propertyName, value, bean);
}
setFieldValue(bean, field, value);
return;
}
} catch (IllegalAccessException | LinkageError e) {
// Continue to error handling
}
}
// If we get here, we couldn't set the property
if (methodInfo == null && field == null) {
throw new ComponentConfigurationException(
configuration, "Cannot find '" + propertyName + "' in " + beanType);
}
}
/**
* Find method using cache for improved performance.
*/
private MethodInfo findCachedMethod(Class<?> beanType, String propertyName, Class<?> valueType) {
Map<String, MethodInfo> classMethodCache = METHOD_CACHE.computeIfAbsent(beanType, this::buildMethodCache);
String title = Character.toTitleCase(propertyName.charAt(0)) + propertyName.substring(1);
// Try setter first
MethodInfo setter = classMethodCache.get("set" + title);
if (setter != null && isMethodCompatible(setter.method, valueType)) {
return setter;
}
View on GitHub (pinned to e4093d4e12)
Solutions
- Check the goal's actual parameters and fix the element name: mvn help:describe -Dplugin=groupId:artifactId:version -Dgoal=<goal> -Ddetail
- Pin the plugin version you wrote the configuration for (parameters differ across versions) via pluginManagement
- If the parameter was removed in the plugin version you use, delete the element from the configuration
- For your own components, add a setFoo(...) setter or a foo field to the implementation class
Example fix
<!-- before: element matches no property -->
<configuration>
<destDir>${project.build.directory}/site</destDir>
</configuration>
<!-- after: use a parameter the goal declares -->
<configuration>
<outputDirectory>${project.build.directory}/site</outputDirectory>
</configuration> Defensive patterns
Strategy: validation
Validate before calling
// Before applying foreign configuration XML, verify each element maps to a property
Set<String> writable = new HashSet<>();
for (Method m : mojo.getClass().getMethods()) {
if (m.getParameterCount() == 1) {
writable.add(fromCamel(m.getName().startsWith("set") ? m.getName().substring(3) : null));
}
}
for (PlexusConfiguration child : configuration.getChildren()) {
if (!writable.contains(child.getName())) {
throw new IllegalArgumentException("Unknown configuration element: " + child.getName());
}
} Prevention
- Generate configuration skeletons from the goal descriptor (mvn help:describe -Ddetail) instead of hand-copying
- Pin plugin versions so parameter sets are stable
- Treat any 'element not found' as a naming mismatch first — check spelling against the parameter list before debugging deeper
When it happens
Trigger: A mojo/component <configuration> block containing an XML element whose name (converted from XML naming) matches no setX/addX method and no declared non-static field on the mojo or configured component. Note the companion behavior: if a setter exists but its invocation fails, the helper silently falls through and this error is NOT thrown.
Common situations: Typo in a configuration parameter name; using a parameter that an older plugin version had but a newer one renamed or removed; copy-pasting configuration between goals that do not share parameters; configuring a component whose implementation class changed between releases.
Related errors
- Cannot set default
- Cannot find permitted subclass '{}' for sealed type {}
- Implementation hint '{}' is ambiguous for sealed type {}: {}
- Cannot read metadata from '{}'
- Unable to lookup org.eclipse.aether.RepositorySystem
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/2e6df0e79319c96f.
Report an issue: GitHub.