quarkusio/quarkus · error · RuntimeException
Could not write DOM from [<path>]
Error message
Could not write DOM from [<path>]
What it means
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.
Source
Thrown at independent-projects/tools/devtools-common/src/main/java/io/quarkus/maven/utilities/PomTransformer.java:91
/**
* Loads the document under {@link #path}, applies the given {@code transformations}, mitigates the formatting
* issues caused by {@link Transformer} and finally stores the document back to the file under {@link #path}.
*
* @param transformations the {@link Transformation}s to apply
*/
public void transform(Collection<Transformation> transformations) {
transform(transformations, path, () -> {
try {
return Files.readString(path, charset);
} catch (IOException e) {
throw new RuntimeException(String.format("Could not read DOM from [%s]", path), e);
}
}, xml -> {
try {
Files.write(path, xml.getBytes(charset));
} catch (IOException e) {
throw new RuntimeException(String.format("Could not write DOM from [%s]", path), e);
}
});
}
static void transform(Collection<Transformation> edits, Path path, Supplier<String> source,
Consumer<String> outConsumer) {
final String src = source.get();
final Document document;
try {
final DOMResult domResult = new DOMResult();
TransformerFactory.newInstance().newTransformer()
.transform(new StreamSource(new StringReader(source.get())), domResult);
document = (Document) domResult.getNode();
} catch (TransformerException | TransformerFactoryConfigurationError e) {
throw new RuntimeException(String.format("Could not read DOM from [%s]", path), e);
}
View on GitHub (pinned to e1c734241f)
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
Example fix
// before
// running with a read-only mounted project
new PomTransformer(path, ...).transform(edits); // fails
// after
// mount rw and ensure permissions
Files.setPosixFilePermissions(path, PosixFilePermissions.fromString("rw-r--r--"));
new PomTransformer(path, ...).transform(edits); Defensive patterns
Strategy: validation
Validate before calling
if (!Files.isWritable(path)) {
throw new IllegalStateException("pom not writable: " + path);
}
if (Files.exists(path) && !Files.isRegularFile(path)) {
throw new IllegalStateException("pom path is not a regular file: " + path);
} Try / catch
try {
transformer.transform(edits);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Could not write DOM")) {
throw new IllegalStateException("Pom not writable at " + path, e.getCause());
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not read DOM from [<path>]
- Unable to create directory: ${directory}
- Unable to collect the target directories
- Unable to update the pom.xml file
- Could not create directory ${outputDirectory}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/a78ad4c296b7247a.
Report an issue: GitHub.