{"record":{"id":"2ab6aa1ada87b998","repo":"apache/maven","slug":"unable-to-write-plugin","errorCode":null,"errorMessage":"Unable to write plugin: ","messagePattern":"Unable to write plugin: ","errorType":"exception","errorClass":"XmlWriterException","httpStatus":null,"severity":"error","filePath":"impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultPluginXmlFactory.java","lineNumber":102,"sourceCode":"        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);\n            } else {\n                try (OutputStream os = Files.newOutputStream(path)) {\n                    new PluginDescriptorStaxWriter().write(os, content);\n                }\n            }\n        } catch (Exception e) {\n            throw new XmlWriterException(\"Unable to write plugin: \" + getMessage(e), getLocation(e), e);\n        }\n    }\n\n    /**\n     * Simply parse the given xml string.\n     *\n     * @param xml the input XML string\n     * @return the parsed object\n     * @throws XmlReaderException if an error occurs during the parsing\n     * @see #toXmlString(Object)\n     */\n    public static PluginDescriptor fromXml(@Nonnull String xml) throws XmlReaderException {\n        return new DefaultPluginXmlFactory().fromXmlString(xml);\n    }\n\n    /**\n     * Simply converts the given content to an XML string.\n     *","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultPluginXmlFactory.java#L84-L120","documentation":"Wrapper thrown by DefaultPluginXmlFactory.write when serializing a PluginDescriptor fails: STaX writer errors or IOException while opening and writing the target path. The real failure is preserved as the cause and its message and location are appended.","triggerScenarios":"Writing a descriptor to a path whose parent directory does not exist or is not writable; XMLStreamWriter failures; disk-full conditions during the write.","commonSituations":"Regenerating plugin.xml into a build output directory that does not exist yet; read-only source trees in CI sandboxes.","solutions":["Unwrap getCause() to see the actual IOException or XMLStreamException","Run Files.createDirectories(path.getParent()) before the write","Verify write permission on the target directory in the failing environment"],"exampleFix":"// before\npluginXmlFactory.write(XmlWriterRequest.builder()\n    .content(descriptor)\n    .path(outputDir.resolve(\"plugin.xml\"))\n    .build());\n\n// after\nFiles.createDirectories(outputDir);\npluginXmlFactory.write(XmlWriterRequest.builder()\n    .content(descriptor)\n    .path(outputDir.resolve(\"plugin.xml\"))\n    .build());","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    pluginXmlFactory.write(req);\n} catch (XmlWriterException e) {\n    if (e.getCause() instanceof IOException io) {\n        // create parent directories / fix permissions, then retry once\n    } else {\n        throw e;\n    }\n}","preventionTips":["Create output directories during build preparation, not during writes","Verify write permissions of the target directory in CI before the build starts"],"tags":["maven","xml","plugin-descriptor","io","serialization"],"backgroundTag":"xml-write-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}