{"record":{"id":"a78ad4c296b7247a","repo":"quarkusio/quarkus","slug":"could-not-write-dom-from-path","errorCode":null,"errorMessage":"Could not write DOM from [<path>]","messagePattern":"Could not write DOM from \\[<path>\\]","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/devtools-common/src/main/java/io/quarkus/maven/utilities/PomTransformer.java","lineNumber":91,"sourceCode":"\n    /**\n     * Loads the document under {@link #path}, applies the given {@code transformations}, mitigates the formatting\n     * issues caused by {@link Transformer} and finally stores the document back to the file under {@link #path}.\n     *\n     * @param transformations the {@link Transformation}s to apply\n     */\n    public void transform(Collection<Transformation> transformations) {\n        transform(transformations, path, () -> {\n            try {\n                return Files.readString(path, charset);\n            } catch (IOException e) {\n                throw new RuntimeException(String.format(\"Could not read DOM from [%s]\", path), e);\n            }\n        }, xml -> {\n            try {\n                Files.write(path, xml.getBytes(charset));\n            } catch (IOException e) {\n                throw new RuntimeException(String.format(\"Could not write DOM from [%s]\", path), e);\n            }\n        });\n    }\n\n    static void transform(Collection<Transformation> edits, Path path, Supplier<String> source,\n            Consumer<String> outConsumer) {\n        final String src = source.get();\n\n        final Document document;\n        try {\n            final DOMResult domResult = new DOMResult();\n            TransformerFactory.newInstance().newTransformer()\n                    .transform(new StreamSource(new StringReader(source.get())), domResult);\n            document = (Document) domResult.getNode();\n        } catch (TransformerException | TransformerFactoryConfigurationError e) {\n            throw new RuntimeException(String.format(\"Could not read DOM from [%s]\", path), e);\n        }\n","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/devtools-common/src/main/java/io/quarkus/maven/utilities/PomTransformer.java#L73-L109","documentation":"PomTransformer.transform(Collection<Transformation>) writes the transformed XML back to the pom path with Files.write inside a consumer; an IOException is rethrown as RuntimeException 'Could not write DOM from [<path>]'. The DOM was built fine but persisting it failed.","triggerScenarios":"The write-back step of transform(...) fails because the file is read-only, the directory is not writable, the file was deleted mid-run, or disk issues occur.","commonSituations":"pom.xml checked out read-only, running in a container with a read-only filesystem, IDE/file watchers locking the file on Windows, full disk.","solutions":["Make pom.xml writable (chmod u+w / remove read-only flag)","Ensure the project directory is writable by the process user","Check available disk space and filesystem mount mode (not read-only)","Re-run the transformation after closing programs locking the file"],"exampleFix":"// before\n// running with a read-only mounted project\nnew PomTransformer(path, ...).transform(edits); // fails\n// after\n// mount rw and ensure permissions\nFiles.setPosixFilePermissions(path, PosixFilePermissions.fromString(\"rw-r--r--\"));\nnew PomTransformer(path, ...).transform(edits);","handlingStrategy":"validation","validationCode":"if (!Files.isWritable(path)) {\n    throw new IllegalStateException(\"pom not writable: \" + path);\n}\nif (Files.exists(path) && !Files.isRegularFile(path)) {\n    throw new IllegalStateException(\"pom path is not a regular file: \" + path);\n}","typeGuard":null,"tryCatchPattern":"try {\n    transformer.transform(edits);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Could not write DOM\")) {\n        throw new IllegalStateException(\"Pom not writable at \" + path, e.getCause());\n    }\n    throw e;\n}","preventionTips":["Ensure pom.xml has write permission for the running user","Avoid read-only container mounts when running modifying goals","Check disk space before large builds","Close IDE watchers/editors that may lock pom.xml on Windows"],"tags":["maven","io","pom","filesystem","write"],"backgroundTag":"pom-file-unwritable","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}