{"record":{"id":"d34a2ce61184642b","repo":"quarkusio/quarkus","slug":"no-project-in-file-pomxmlpath","errorCode":null,"errorMessage":"No <project> in file [<pomXmlPath>]","messagePattern":"No <project> in file \\[<pomXmlPath>\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/devtools-common/src/main/java/io/quarkus/maven/utilities/PomTransformer.java","lineNumber":278,"sourceCode":"                        final Node modulesIndent = context.indent(1);\n                        modules = document.createElement(\"modules\");\n                        modules.appendChild(context.indent(1));\n\n                        final Node build = (Node) context.getXPath().evaluate(anyNs(\"project\", \"build\"), document,\n                                XPathConstants.NODE);\n                        if (build != null) {\n                            Node ws = build.getPreviousSibling();\n                            if (ws == null || ws.getNodeType() != Node.TEXT_NODE) {\n                                ws = context.indent(1);\n                                build.getParentNode().insertBefore(ws, build);\n                            }\n                            build.getParentNode().insertBefore(modulesIndent, ws);\n                            build.getParentNode().insertBefore(modules, ws);\n                        } else {\n                            final Node project = (Node) context.getXPath().evaluate(anyNs(\"project\"), document,\n                                    XPathConstants.NODE);\n                            if (project == null) {\n                                throw new IllegalStateException(\n                                        String.format(\"No <project> in file [%s]\", context.getPomXmlPath()));\n                            }\n                            final NodeList projectChildren = project.getChildNodes();\n                            final int len = projectChildren.getLength();\n                            Node ws = null;\n                            if (len == 0 || (ws = projectChildren.item(len - 1)).getNodeType() != Node.TEXT_NODE) {\n                                ws = document.createTextNode(\"\\n\");\n                                project.appendChild(ws);\n                            }\n                            project.insertBefore(modulesIndent, ws);\n                            project.insertBefore(modules, ws);\n                        }\n                    }\n\n                    final Node moduleNode = document.createElement(\"module\");\n                    moduleNode.appendChild(document.createTextNode(module));\n\n                    final NodeList modulesChildren = modules.getChildNodes();","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/devtools-common/src/main/java/io/quarkus/maven/utilities/PomTransformer.java#L260-L296","documentation":"PomTransformer.addModule throws IllegalStateException 'No <project> in file [<pomXmlPath>]' when, after failing to locate an existing <build> element, XPath evaluation cannot find a <project> root element in the parsed pom DOM. addModule needs the project root to insert a <build><modules> hierarchy.","triggerScenarios":"Calling addModule(...) on a parsed document whose root is not <project> (any namespace handling aside) — e.g. the file is empty, is not a pom (settings.xml, wrong XML), or the DOM was built from a source that lacks a project element.","commonSituations":"Pointing the transformer at a non-pom XML file, an empty/truncated pom, or a pom with an unexpected root element name/namespace after templating.","solutions":["Verify the target file is a valid pom.xml with a <project> root","Check the file is not empty or truncated","If building poms programmatically, ensure the template contains <project xmlns=\"http://maven.apache.org/POM/4.0.0\">","Point the transformer at the correct path (the module pom, not settings.xml or another XML)"],"exampleFix":"// before\nString template = \"<?xml version=\\\"1.0\\\"?>\\n<foo/>\"; // wrong root\ntransformer.addModule(\"../shared-lib\");\n// after\nString template = \"<?xml version=\\\"1.0\\\"?>\\n<project xmlns=\\\"http://maven.apache.org/POM/4.0.0\\\"></project>\";\ntransformer.addModule(\"../shared-lib\");","handlingStrategy":"validation","validationCode":"String src = Files.readString(pomPath);\nif (!src.contains(\"<project\")) {\n    throw new IllegalStateException(\"File is not a pom (no <project> root): \" + pomPath);\n}","typeGuard":null,"tryCatchPattern":"try {\n    transformer.addModule(\"../shared-lib\");\n} catch (IllegalStateException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"No <project>\")) {\n        throw new IllegalStateException(\"Target file lacks <project> root: \" + pomPath, e);\n    }\n    throw e;\n}","preventionTips":["Confirm the file has a <project> root before invoking addModule","Never point PomTransformer at settings.xml or other non-pom XML","Keep pom templates complete (with namespaced project element) when generating projects","Check for empty/truncated poms after code generation steps"],"tags":["maven","pom","xml","structure"],"backgroundTag":"missing-pom-project-root","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"}