quarkusio/quarkus · error · RuntimeException
Could not read DOM from [<path>]
Error message
Could not read DOM from [<path>]
What it means
PomTransformer.transform(Collection<Transformation>) reads the pom at the configured path with Files.readString inside a supplier; any IOException is rethrown as RuntimeException 'Could not read DOM from [<path>]'. It means the transformer could not load the pom source text to build its DOM.
Source
Thrown at independent-projects/tools/devtools-common/src/main/java/io/quarkus/maven/utilities/PomTransformer.java:85
*
* @param transformations the {@link Transformation}s to apply
*/
public void transform(Transformation... transformations) {
transform(Arrays.asList(transformations));
}
/**
* 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()View on GitHub (pinned to e1c734241f)
Solutions
- Verify the pom path exists and is a regular file before transforming
- Check read permissions for the current user/process
- Run the command from the directory containing pom.xml or pass the correct -f/--pom path
- Close other processes holding a lock on the file
Example fix
// before
new PomTransformer(pomPath, StandardCharsets.UTF_8, NodeSupplier.lastChildOf(null)).transform(edits); // path missing
// after
if (!Files.isRegularFile(pomPath)) {
throw new IllegalStateException("pom not found: " + pomPath);
}
new PomTransformer(pomPath, StandardCharsets.UTF_8, NodeSupplier.lastChildOf(null)).transform(edits); Defensive patterns
Strategy: validation
Validate before calling
if (!Files.isRegularFile(path)) {
throw new IllegalStateException("Expected pom file not found: " + path);
}
if (!Files.isReadable(path)) {
throw new IllegalStateException("pom not readable: " + path);
} Try / catch
try {
transformer.transform(edits);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Could not read DOM")) {
throw new IllegalStateException("Pom unreadable at " + path, e.getCause());
}
throw e;
} Prevention
- Check file existence/readability before constructing the transformer
- Run Maven goals from the project root or pass an explicit pom path
- Avoid holding the pom open in tools that lock it during transformation
- Verify the working directory matches expectations in scripts and IDEs
When it happens
Trigger: Calling pomTransformer.transform(...) when the pom file does not exist, is unreadable (permissions), or the path is a directory; the charset-decoded read fails with IOException.
Common situations: Running an extension/dev-mode goal in a project without a pom.xml at the expected location, wrong working directory, file locked by another process, or permissions changed after construction.
Related errors
- Could not write 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/8e960f6b98db534c.
Report an issue: GitHub.