{"record":{"id":"951ee84ea0f80630","repo":"apache/maven","slug":"cannot-find-default-setter-in","errorCode":null,"errorMessage":"Cannot find default setter in {}","messagePattern":"Cannot find default setter in (.+?)","errorType":"exception","errorClass":"ComponentConfigurationException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/configuration/internal/EnhancedCompositeBeanHelper.java","lineNumber":90,"sourceCode":"\n    /**\n     * Calls the default \"set\" method on the bean; re-converts the configuration if necessary.\n     */\n    public void setDefault(Object bean, Object defaultValue, PlexusConfiguration configuration)\n            throws ComponentConfigurationException {\n\n        Class<?> beanType = bean.getClass();\n\n        // Find the default \"set\" method\n        MethodInfo setterInfo = findCachedMethod(beanType, \"\", null);\n        if (setterInfo == null) {\n            // Look for any method named \"set\" with one parameter\n            Map<String, MethodInfo> classMethodCache = METHOD_CACHE.computeIfAbsent(beanType, this::buildMethodCache);\n            setterInfo = classMethodCache.get(\"set\");\n        }\n\n        if (setterInfo == null) {\n            throw new ComponentConfigurationException(configuration, \"Cannot find default setter in \" + beanType);\n        }\n\n        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                }","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/configuration/internal/EnhancedCompositeBeanHelper.java#L72-L108","documentation":"EnhancedConfigurationConverter instantiates the target bean when a configuration element's evaluated value does not fit the field type, then hands it to EnhancedCompositeBeanHelper.setDefault, which needs a default 'set' method: first a cached no-name lookup, then any single-parameter method literally named 'set'. If the bean's class has neither, configuration cannot proceed and ComponentConfigurationException 'Cannot find default setter in <beanType>' is thrown, naming the class.","triggerScenarios":"A configuration element carrying a text value mapped onto a composite bean whose class exposes no one-arg set(...) method - typically after a dependency/plugin upgrade swapped the option class to one without the composite-friendly set method, or configuration written for a different plugin version.","commonSituations":"Version skew between a plugin and its API/option classes resolved from the dependency tree; hand-written component configuration assuming plexus composite conventions; upgrades of Maven itself tightening composite handling.","solutions":["Inspect the bean class named in the message in the version actually resolved (`mvn dependency:tree -Dincludes=...`) - does it expose a one-arg set method?","Align plugin/tool version with the configuration style used (pin the version that matches).","Rewrite the configuration to bind children to explicit setters/fields instead of the default composite form.","If you own the bean class, add a `set(Value)` method accepting the element content."],"exampleFix":"<!-- before: text value mapped onto a composite bean with no set() method -->\n<extension>\n  <myOption>legacy-value</myOption>\n</extension>\n\n<!-- after: bind to the explicit property setter the bean actually has -->\n<extension>\n  <myOptionValue>legacy-value</myOptionValue>\n</extension>","handlingStrategy":"validation","validationCode":"boolean hasDefaultSetter(Class<?> beanType) {\n    for (Method m : beanType.getMethods()) {\n        if (\"set\".equals(m.getName()) && m.getParameterCount() == 1) return true;\n    }\n    return false;\n}\nif (!hasDefaultSetter(beanType)) {\n    throw new IllegalArgumentException(\"Bean \" + beanType + \" cannot take composite default value; fix configuration\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin plugin/dependency versions so option classes match the configuration style you use.","When writing plugin configuration, target explicit setters/fields rather than the composite default form.","After upgrades, run `mvn dependency:tree` to confirm expected option-class versions resolve."],"tags":["maven","plugin-configuration","bean-binding","reflection"],"backgroundTag":"plugin-configuration-binding-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}