{"record":{"id":"79cb22d867b2887f","repo":"quarkusio/quarkus","slug":"project-not-found-in-pomxmlpath","errorCode":null,"errorMessage":"//project not found in [<pomXmlPath>]","messagePattern":"//project not found in \\[<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":376,"sourceCode":"                } catch (XPathExpressionException | DOMException e) {\n                    throw new RuntimeException(e);\n                }\n            };\n        }\n\n        public static Transformation addDependencyManagementIfNeeded() {\n            return (Document document, TransformationContext context) -> {\n                try {\n                    Node dependencyManagementDeps = (Node) context.getXPath().evaluate(\n                            anyNs(\"project\", \"dependencyManagement\", \"dependencies\"), document, XPathConstants.NODE);\n                    if (dependencyManagementDeps == null) {\n                        Node dependencyManagement = (Node) context.getXPath()\n                                .evaluate(anyNs(\"project\", \"dependencyManagement\"), document, XPathConstants.NODE);\n                        if (dependencyManagement == null) {\n                            Node project = (Node) context.getXPath().evaluate(anyNs(\"project\"), document,\n                                    XPathConstants.NODE);\n                            if (project == null) {\n                                throw new IllegalStateException(\n                                        String.format(\"//project not found in [%s]\", context.getPomXmlPath()));\n                            }\n                            /* ideally before dependencies */\n                            Node refNode = (Node) context.getXPath().evaluate(anyNs(\"project\", \"dependencies\"),\n                                    document, XPathConstants.NODE);\n                            if (refNode == null) {\n                                /* or before build */\n                                refNode = (Node) context.getXPath().evaluate(anyNs(\"project\", \"build\"),\n                                        document, XPathConstants.NODE);\n                            }\n                            dependencyManagement = document.createElement(\"dependencyManagement\");\n                            Node ws;\n                            if (refNode != null) {\n                                ws = refNode.getPreviousSibling();\n                                if (ws == null || ws.getNodeType() != Node.TEXT_NODE) {\n                                    project.insertBefore(ws = context.indent(1), refNode);\n                                }\n                            } else {","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/devtools-common/src/main/java/io/quarkus/maven/utilities/PomTransformer.java#L358-L394","documentation":"addDependencyManagementIfNeeded (reached via addManagedDependency) tries to add a <dependencyManagement> section. If that section is missing it re-looks-up the <project> root to anchor the new section; when even the root is absent it throws this IllegalStateException. The target file is XML but not a valid Maven POM.","triggerScenarios":"Calling addManagedDependency (which delegates to addDependencyManagementIfNeeded) on a pom document with no <project> element — wrong file, empty/corrupt document, or non-Maven XML.","commonSituations":"Quarkus platform/dependency injection tooling pointed at a generated or template XML file lacking a POM root; truncated pom after a bad download or interrupted write.","solutions":["Check the file at pomXmlPath has a proper <project xmlns=\"http://maven.apache.org/POM/4.0.0\"> root","Restore or regenerate the pom.xml from the archetype or git history","Confirm the tool is targeting the intended pom.xml, not an unrelated XML file","Run `mvn validate` on the file first to catch malformed POMs early"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"Document doc = ...parse(pomFile);\nif (doc.getElementsByTagNameNS(\"http://maven.apache.org/POM/4.0.0\", \"project\").getLength() == 0) {\n    throw new IllegalArgumentException(pomFile + \" has no <project> root\");\n}","typeGuard":"boolean hasProjectRoot(Document d) {\n    return d.getDocumentElement() != null && d.getDocumentElement().getNodeName().equals(\"project\");\n}","tryCatchPattern":"try {\n    transformer.addManagedDependency(...);\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"//project not found\")) {\n        throw new IllegalStateException(\"pom.xml is malformed; restore it before adding managed dependencies\", e);\n    }\n    throw e;\n}","preventionTips":["Verify pom root element before programmatic edits","Restore poms from git rather than editing broken files","Target only files produced by known-good generators/archetypes"],"tags":["maven","pom","dependency-management"],"backgroundTag":"invalid-pom-structure","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"}