{"record":{"id":"51cfbf2e9209e363","repo":"apache/maven","slug":"unable-to-read-plugin","errorCode":null,"errorMessage":"Unable to read plugin: ","messagePattern":"Unable to read plugin: ","errorType":"exception","errorClass":"XmlReaderException","httpStatus":null,"severity":"error","filePath":"impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultPluginXmlFactory.java","lineNumber":77,"sourceCode":"            PluginDescriptorStaxReader xml = request.getTransformer() != null\n                    ? new PluginDescriptorStaxReader(request.getTransformer()::transform)\n                    : new PluginDescriptorStaxReader();\n            xml.setAddDefaultEntities(request.isAddDefaultEntities());\n            if (inputStream != null) {\n                return xml.read(inputStream, request.isStrict());\n            } else if (reader != null) {\n                return xml.read(reader, request.isStrict());\n            } else if (path != null) {\n                try (InputStream is = Files.newInputStream(path)) {\n                    return xml.read(is, request.isStrict());\n                }\n            } else {\n                try (InputStream is = url.openStream()) {\n                    return xml.read(is, request.isStrict());\n                }\n            }\n        } catch (Exception e) {\n            throw new XmlReaderException(\"Unable to read plugin: \" + getMessage(e), getLocation(e), e);\n        }\n    }\n\n    @Override\n    public void write(XmlWriterRequest<PluginDescriptor> request) throws XmlWriterException {\n        requireNonNull(request, \"request\");\n        PluginDescriptor content = requireNonNull(request.getContent(), \"content\");\n        Path path = request.getPath();\n        OutputStream outputStream = request.getOutputStream();\n        Writer writer = request.getWriter();\n        if (writer == null && outputStream == null && path == null) {\n            throw new IllegalArgumentException(\"writer, outputStream or path must be non null\");\n        }\n        try {\n            if (writer != null) {\n                new PluginDescriptorStaxWriter().write(writer, content);\n            } else if (outputStream != null) {\n                new PluginDescriptorStaxWriter().write(outputStream, content);","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultPluginXmlFactory.java#L59-L95","documentation":"Wrapper thrown when parsing a PluginDescriptor (plugin.xml) fails: malformed XML, strict-mode rejection of unknown elements, or IO errors while opening the path or URL. The underlying exception is preserved as the cause; STaX causes carry line and column information which the factory appends to the message.","triggerScenarios":"Feeding a malformed or truncated plugin.xml; strict mode active while the descriptor contains elements unknown to the bundled descriptor model; an unreadable path or a URL whose openStream() fails.","commonSituations":"Reading plugin descriptors generated by a different maven-plugin-tools version than the runtime model expects; descriptors corrupted during packaging; URL sources behind proxies that return error pages instead of XML.","solutions":["Read getCause() - XMLStreamException messages include the line and column of the failure","Set .strict(false) on the request when unknown elements are expected and tolerable","Validate the descriptor XML externally (xmllint) before passing it in","For URL sources, fetch and inspect what the server actually returns before parsing"],"exampleFix":"// before\nPluginDescriptor pd = pluginXmlFactory.read(XmlReaderRequest.builder()\n    .path(descriptorPath)\n    .build()); // strict default may reject unknown tags\n\n// after\nPluginDescriptor pd = pluginXmlFactory.read(XmlReaderRequest.builder()\n    .path(descriptorPath)\n    .strict(false)\n    .build());","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    PluginDescriptor pd = pluginXmlFactory.read(req);\n} catch (XmlReaderException e) {\n    Throwable cause = e.getCause();\n    // XMLStreamException: line/column of parse failure; IOException: unreadable source\n    log.error(\"plugin.xml invalid: {} at {}\", e.getMessage(), e.getLocation(), cause);\n}","preventionTips":["Use strict(false) when parsing descriptors from foreign plugin-tools versions","Validate plugin.xml well-formedness before feeding it to the factory","For URL sources, confirm the server returns XML, not an error page"],"tags":["maven","xml","plugin-descriptor","parse"],"backgroundTag":"xml-parse-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}