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

  1. Check the goal's actual parameters and fix the element name: mvn help:describe -Dplugin=groupId:artifactId:version -Dgoal=<goal> -Ddetail
  2. Pin the plugin version you wrote the configuration for (parameters differ across versions) via pluginManagement
  3. If the parameter was removed in the plugin version you use, delete the element from the configuration
  4. 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

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


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