{"record":{"id":"30c69b3fcb41b16b","repo":"apache/maven","slug":"cannot-set-default","errorCode":null,"errorMessage":"Cannot set default","messagePattern":"Cannot set default","errorType":"exception","errorClass":"ComponentConfigurationException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/configuration/internal/EnhancedCompositeBeanHelper.java","lineNumber":111,"sourceCode":"        Object value = defaultValue;\n        TypeLiteral<?> paramType = TypeLiteral.get(setterInfo.parameterType);\n\n        if (!paramType.getRawType().isInstance(value)) {\n            if (configuration.getChildCount() > 0) {\n                throw new ComponentConfigurationException(\n                        \"Basic element '\" + configuration.getName() + \"' must not contain child elements\");\n            }\n            value = convertProperty(beanType, paramType.getRawType(), paramType.getType(), configuration);\n        }\n\n        if (value != null) {\n            try {\n                if (listener != null) {\n                    listener.notifyFieldChangeUsingSetter(\"\", value, bean);\n                }\n                setterInfo.method.invoke(bean, value);\n            } catch (IllegalAccessException | InvocationTargetException | LinkageError e) {\n                throw new ComponentConfigurationException(configuration, \"Cannot set default\", e);\n            }\n        }\n    }\n\n    /**\n     * Sets a property in the bean using cached lookups for improved performance.\n     */\n    public void setProperty(Object bean, String propertyName, Class<?> valueType, PlexusConfiguration configuration)\n            throws ComponentConfigurationException {\n\n        Class<?> beanType = bean.getClass();\n\n        // Try setter/adder methods first\n        MethodInfo methodInfo = findCachedMethod(beanType, propertyName, valueType);\n        if (methodInfo != null) {\n            try {\n                Object value = convertPropertyForMethod(beanType, methodInfo, valueType, configuration);\n                if (value != null) {","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/configuration/internal/EnhancedCompositeBeanHelper.java#L93-L129","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Unwrap the cause: e.getCause() of the ComponentConfigurationException; for InvocationTargetException look at getTargetException() to see what the setter actually threw","If the cause is IllegalArgumentException/ClassCastException, fix the plugin configuration element so the converted value matches the setter's parameter type","If IllegalAccessException, upgrade the plugin/component to a version compatible with the running JDK or open the package to reflective access","If LinkageError/NoClassDefFoundError, refresh the plugin realm: mvn -U, remove conflicting plugin versions, verify plugin dependencies resolve"],"exampleFix":"<!-- before: value the set(...) method rejects -->\n<configuration>\n  <timeout>soon</timeout> <!-- setTimeout(long) throws IllegalArgumentException -->\n</configuration>\n\n<!-- after: value valid for the setter parameter type -->\n<configuration>\n  <timeout>30</timeout>\n</configuration>","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    componentConfigurator.configureComponent(bean, configuration, evaluator, realm);\n} catch (ComponentConfigurationException e) {\n    Throwable cause = e.getCause();\n    if (cause instanceof InvocationTargetException ite) {\n        cause = ite.getTargetException(); // the setter's real exception\n    }\n    log.error(\"Setter rejected configured value: {}\", cause, cause);\n}","preventionTips":["Keep plugin configuration values aligned with the documented parameter types of the exact plugin version pinned in pluginManagement","Test plugin upgrades on a scratch branch and run the goals that exercise custom setters","Inspect cause chains before assuming the configuration XML itself is wrong"],"tags":["maven","plexus","plugin-configuration","reflection","component-configuration"],"backgroundTag":"reflection-invocation-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}