{"record":{"id":"ddb68958f9b315b2","repo":"apache/maven","slug":"cannot-convert-s-to-s","errorCode":null,"errorMessage":"Cannot convert: \"%s\" to: %s","messagePattern":"Cannot convert: \"(.+?)\" to: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compat/maven-embedder/src/main/java/org/eclipse/sisu/plexus/PlexusXmlBeanConverter.java","lineNumber":93,"sourceCode":"    PlexusXmlBeanConverter(final Injector injector) {\n        typeConverterBindings = injector.getTypeConverterBindings();\n    }\n\n    // ----------------------------------------------------------------------\n    // Public methods\n    // ----------------------------------------------------------------------\n\n    @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n    public Object convert(final TypeLiteral role, final String value) {\n        if (value.trim().startsWith(\"<\")) {\n            try {\n                final MXParser parser = new MXParser();\n                parser.setInput(new StringReader(value));\n                parser.nextTag();\n\n                return parse(parser, role);\n            } catch (final Exception e) {\n                throw new IllegalArgumentException(String.format(CONVERSION_ERROR, value, role), e);\n            }\n        }\n\n        return convertText(value, role);\n    }\n\n    // ----------------------------------------------------------------------\n    // Implementation methods\n    // ----------------------------------------------------------------------\n\n    /**\n     * Parses a sequence of XML elements and converts them to the given target type.\n     *\n     * @param parser The XML parser\n     * @param toType The target type\n     * @return Converted instance of the target type\n     */\n    private Object parse(final MXParser parser, final TypeLiteral<?> toType) throws Exception {","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-embedder/src/main/java/org/eclipse/sisu/plexus/PlexusXmlBeanConverter.java#L75-L111","documentation":"Thrown by Sisu's Plexus XML bean converter when a configuration value that starts with '<' cannot be parsed as XML and converted into the requested role type (TypeLiteral). The converter only attempts XML parsing for values whose trimmed form looks like markup; any parser or conversion failure inside that path (malformed XML, unknown bean property, failed instantiation) is rethrown as an IllegalArgumentException wrapping the original cause.","triggerScenarios":"Calling PlexusXmlBeanConverter.convert(TypeLiteral, String) directly or via Sisu/Plexus configuration injection, with a value whose trimmed form starts with '<' but is malformed XML, references unknown elements, or targets a type/implementation that cannot accept the parsed content.","commonSituations":"Hand-edited plexus.xml/components.xml with mismatched tags or wrong element names inside <configuration>; component upgrades that renamed bean properties so previously valid inline XML no longer maps; embedding Sisu with custom bean types that lack a default constructor.","solutions":["Read the caused-by chain: the nested exception holds the real failure (XmlPullParserException, 'Unknown bean property', 'Cannot create instance')","Validate the inline XML fragment is well-formed: matching tags, no stray characters before the first '<'","Check every element name against the target bean's writable properties; element names are camelized (max-retries -> maxRetries)","Ensure any class named via implementation= or a nested <implementation> element has a public no-arg constructor","If the value is not meant to be XML, remove the leading '<' so the converter uses the plain-text path"],"exampleFix":"// before: plexus.xml - mismatched tag inside inline XML value\n<component>\n  <role>com.example.Server</role>\n  <implementation>com.example.Server</implementation>\n  <configuration>\n    <hosts><host>alpha</hosts></hosts>\n  </configuration>\n</component>\n\n// after: well-formed XML that maps onto the Server bean\n<component>\n  <role>com.example.Server</role>\n  <implementation>com.example.Server</implementation>\n  <configuration>\n    <hosts><host>alpha</host></hosts>\n  </configuration>\n</component>","handlingStrategy":"try-catch","validationCode":"// Pre-check: only values that look like XML go down the XML path\nString v = value == null ? \"\" : value.trim();\nif (v.startsWith(\"<\")) {\n    try {\n        MXParser p = new MXParser();\n        p.setInput(new StringReader(v));\n        p.nextTag(); // throws on malformed markup before the converter runs\n    } catch (Exception e) {\n        throw new IllegalArgumentException(\"Malformed inline XML config\", e);\n    }\n}\nObject converted = converter.convert(role, value);","typeGuard":null,"tryCatchPattern":"try {\n    Object v = converter.convert(role, value);\n} catch (IllegalArgumentException e) {\n    // the real reason is nested: XmlPullParserException / unknown property / instantiation\n    Throwable root = e.getCause() != null ? e.getCause() : e;\n    log.warn(\"Sisu conversion failed for {}: {}\", role, root.getMessage());\n}","preventionTips":["Keep inline XML values in plexus.xml/components.xml minimal; prefer plain text for scalars","Lint component configuration XML (e.g. xmllint) in CI so malformed values fail early","Pin component versions so element names stay aligned with the bean's setters"],"tags":["xml","plexus","sisu","type-conversion","configuration"],"backgroundTag":"config-type-conversion-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}