{"record":{"id":"8e960f6b98db534c","repo":"quarkusio/quarkus","slug":"could-not-read-dom-from-path","errorCode":null,"errorMessage":"Could not read DOM from [<path>]","messagePattern":"Could not read 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":85,"sourceCode":"     *\n     * @param transformations the {@link Transformation}s to apply\n     */\n    public void transform(Transformation... transformations) {\n        transform(Arrays.asList(transformations));\n    }\n\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()","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/devtools-common/src/main/java/io/quarkus/maven/utilities/PomTransformer.java#L67-L103","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nnew PomTransformer(pomPath, StandardCharsets.UTF_8, NodeSupplier.lastChildOf(null)).transform(edits); // path missing\n// after\nif (!Files.isRegularFile(pomPath)) {\n    throw new IllegalStateException(\"pom not found: \" + pomPath);\n}\nnew PomTransformer(pomPath, StandardCharsets.UTF_8, NodeSupplier.lastChildOf(null)).transform(edits);","handlingStrategy":"validation","validationCode":"if (!Files.isRegularFile(path)) {\n    throw new IllegalStateException(\"Expected pom file not found: \" + path);\n}\nif (!Files.isReadable(path)) {\n    throw new IllegalStateException(\"pom not readable: \" + path);\n}","typeGuard":null,"tryCatchPattern":"try {\n    transformer.transform(edits);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Could not read DOM\")) {\n        throw new IllegalStateException(\"Pom unreadable at \" + path, e.getCause());\n    }\n    throw e;\n}","preventionTips":["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"],"tags":["maven","io","pom","filesystem"],"backgroundTag":"pom-file-unreadable","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"}