quarkusio/quarkus · error · IllegalStateException
//project not found in [<pomXmlPath>]
Error message
//project not found in [<pomXmlPath>]
What it means
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.
Source
Thrown at independent-projects/tools/devtools-common/src/main/java/io/quarkus/maven/utilities/PomTransformer.java:376
} catch (XPathExpressionException | DOMException e) {
throw new RuntimeException(e);
}
};
}
public static Transformation addDependencyManagementIfNeeded() {
return (Document document, TransformationContext context) -> {
try {
Node dependencyManagementDeps = (Node) context.getXPath().evaluate(
anyNs("project", "dependencyManagement", "dependencies"), document, XPathConstants.NODE);
if (dependencyManagementDeps == null) {
Node dependencyManagement = (Node) context.getXPath()
.evaluate(anyNs("project", "dependencyManagement"), document, XPathConstants.NODE);
if (dependencyManagement == null) {
Node project = (Node) context.getXPath().evaluate(anyNs("project"), document,
XPathConstants.NODE);
if (project == null) {
throw new IllegalStateException(
String.format("//project not found in [%s]", context.getPomXmlPath()));
}
/* ideally before dependencies */
Node refNode = (Node) context.getXPath().evaluate(anyNs("project", "dependencies"),
document, XPathConstants.NODE);
if (refNode == null) {
/* or before build */
refNode = (Node) context.getXPath().evaluate(anyNs("project", "build"),
document, XPathConstants.NODE);
}
dependencyManagement = document.createElement("dependencyManagement");
Node ws;
if (refNode != null) {
ws = refNode.getPreviousSibling();
if (ws == null || ws.getNodeType() != Node.TEXT_NODE) {
project.insertBefore(ws = context.indent(1), refNode);
}
} else {View on GitHub (pinned to e1c734241f)
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
Defensive patterns
Strategy: validation
Validate before calling
Document doc = ...parse(pomFile);
if (doc.getElementsByTagNameNS("http://maven.apache.org/POM/4.0.0", "project").getLength() == 0) {
throw new IllegalArgumentException(pomFile + " has no <project> root");
} Type guard
boolean hasProjectRoot(Document d) {
return d.getDocumentElement() != null && d.getDocumentElement().getNodeName().equals("project");
} Try / catch
try {
transformer.addManagedDependency(...);
} catch (IllegalStateException e) {
if (e.getMessage().startsWith("//project not found")) {
throw new IllegalStateException("pom.xml is malformed; restore it before adding managed dependencies", e);
}
throw e;
} Prevention
- 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
When it happens
Trigger: Calling addManagedDependency (which delegates to addDependencyManagementIfNeeded) on a pom document with no <project> element — wrong file, empty/corrupt document, or non-Maven XML.
Common situations: 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.
Related errors
- Unable to parse pom file: ${pom}
- Could not resolve POM for
- Unable to update the pom.xml file
- The parent project must have a packaging type of POM. Curren
- Unable to update the pom.xml file
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/79cb22d867b2887f.
Report an issue: GitHub.