{"record":{"id":"52b613e36dac28d3","repo":"apache/maven","slug":"basic-element-must-not-contain-child-elements","errorCode":null,"errorMessage":"Basic element '{}' must not contain child elements","messagePattern":"Basic element '(.+?)' must not contain child elements","errorType":"exception","errorClass":"ComponentConfigurationException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/configuration/internal/EnhancedCompositeBeanHelper.java","lineNumber":98,"sourceCode":"\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                }\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    /**","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/configuration/internal/EnhancedCompositeBeanHelper.java#L80-L116","documentation":"In the same composite-binding path, when the resolved value is not an instance of the set(...) parameter type, EnhancedCompositeBeanHelper falls back to converting the element's text via convertProperty - but only if the element has no child elements; a basic (scalar) element carrying nested XML is structurally invalid and throws ComponentConfigurationException \"Basic element '<name>' must not contain child elements\".","triggerScenarios":"Configuration like `<threadCount><max>4</max></threadCount>` where the target set(...) accepts a scalar (e.g. String or int): the child elements make text conversion impossible.","commonSituations":"Upgrading a plugin whose parameter changed from a composite type to a simple type while old configuration kept nested XML; copy-pasting configuration between parameters of different shapes; stale examples in docs.","solutions":["Flatten the element: give it text content (`<threadCount>4</threadCount>`) instead of children.","Check the parameter's declared type for your plugin version and reshape the configuration to match.","Pin or upgrade to the plugin version whose configuration style the existing XML follows."],"exampleFix":"<!-- before -->\n<configuration>\n  <threadCount><max>4</max></threadCount>\n</configuration>\n\n<!-- after -->\n<configuration>\n  <threadCount>4</threadCount>\n</configuration>","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    configurator.configureBean(request);\n} catch (BeanConfigurationException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"must not contain child elements\")) {\n        reportNestedScalarParameter(e); // flatten <param><child>x</child></param> to <param>x</param>\n    } else {\n        throw e;\n    }\n}","preventionTips":["Match configuration shape to the parameter type: scalar types get text, not children.","Re-check plugin docs after upgrades for parameters that changed from composite to simple types."],"tags":["maven","plugin-configuration","bean-binding","xml"],"backgroundTag":"plugin-configuration-binding-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}