apache/maven · error · ComponentConfigurationException

Cannot set default

Error message

Cannot set default

What it means

Thrown by Plexus/Sisu bean configuration when the reflective call to a component's default 'set' method fails. EnhancedCompositeBeanHelper.setDefault() finds a one-argument method named 'set' on the bean, converts the configuration value, and invokes it via reflection; if the invoke throws IllegalAccessException, InvocationTargetException (the setter body itself threw), or a LinkageError, it is wrapped as ComponentConfigurationException('Cannot set default'). The real failure is always in the cause chain.

Source

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

        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);
            }
        }
    }

    /**
     * Sets a property in the bean using cached lookups for improved performance.
     */
    public void setProperty(Object bean, String propertyName, Class<?> valueType, PlexusConfiguration configuration)
            throws ComponentConfigurationException {

        Class<?> beanType = bean.getClass();

        // Try setter/adder methods first
        MethodInfo methodInfo = findCachedMethod(beanType, propertyName, valueType);
        if (methodInfo != null) {
            try {
                Object value = convertPropertyForMethod(beanType, methodInfo, valueType, configuration);
                if (value != null) {

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Unwrap the cause: e.getCause() of the ComponentConfigurationException; for InvocationTargetException look at getTargetException() to see what the setter actually threw
  2. If the cause is IllegalArgumentException/ClassCastException, fix the plugin configuration element so the converted value matches the setter's parameter type
  3. If IllegalAccessException, upgrade the plugin/component to a version compatible with the running JDK or open the package to reflective access
  4. If LinkageError/NoClassDefFoundError, refresh the plugin realm: mvn -U, remove conflicting plugin versions, verify plugin dependencies resolve

Example fix

<!-- before: value the set(...) method rejects -->
<configuration>
  <timeout>soon</timeout> <!-- setTimeout(long) throws IllegalArgumentException -->
</configuration>

<!-- after: value valid for the setter parameter type -->
<configuration>
  <timeout>30</timeout>
</configuration>
Defensive patterns

Strategy: try-catch

Try / catch

try {
    componentConfigurator.configureComponent(bean, configuration, evaluator, realm);
} catch (ComponentConfigurationException e) {
    Throwable cause = e.getCause();
    if (cause instanceof InvocationTargetException ite) {
        cause = ite.getTargetException(); // the setter's real exception
    }
    log.error("Setter rejected configured value: {}", cause, cause);
}

Prevention

When it happens

Trigger: A mojo/component configuration element applied through the bean's single-argument set(...) method where (a) the setter body rejects the converted value with IllegalArgumentException/NullPointerException (arrives as InvocationTargetException), (b) reflective access to the method is denied (IllegalAccessException, JPMS/security manager), or (c) the bean's class or a referenced class fails to link (LinkageError such as NoClassDefFoundError inside the plugin realm).

Common situations: Plugin configuration value of the wrong type reaching a validating setter; plugin built for an older Plexus/JDK run on modern JDKs with stronger encapsulation; stale or conflicting classes in a plugin classrealm after partial upgrades.

Related errors


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