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

  1. Verify the pom path exists and is a regular file before transforming
  2. Check read permissions for the current user/process
  3. Run the command from the directory containing pom.xml or pass the correct -f/--pom path
  4. 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

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


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/8e960f6b98db534c. Report an issue: GitHub.