apache/maven · error · IOException
No pom.xml found in directory: {}
Error message
No pom.xml found in directory: {} What it means
The mvnup upgrade tool begins POM discovery by resolving startDirectory/pom.xml; PomDiscovery.discoverPoms throws IOException 'No pom.xml found in directory' when that file does not exist, before any module walk happens. The tool requires the directory it runs in (or is pointed at) to contain a POM. The message names the directory that was searched.
Source
Thrown at impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/PomDiscovery.java:64
private PomDiscovery() {
// noop
}
/**
* Discovers and loads all POM files starting from the given directory.
*
* @param startDirectory the directory to start discovery from
* @return a map of Path to Document for all discovered POM files
* @throws IOException if there's an error reading files
* @throws DomTripException if there's an error parsing XML
*/
public static Map<Path, Document> discoverPoms(Path startDirectory) throws IOException, DomTripException {
Map<Path, Document> pomMap = new HashMap<>();
// Find and load the root POM
Path rootPomPath = startDirectory.resolve(POM_XML);
if (!Files.exists(rootPomPath)) {
throw new IOException("No pom.xml found in directory: " + startDirectory);
}
Document rootPom = loadPom(rootPomPath);
pomMap.put(rootPomPath, rootPom);
// Recursively discover modules
discoverModules(startDirectory, rootPom, pomMap);
return pomMap;
}
/**
* Loads a POM file as a domtrip Document.
*
* @param pomPath the path to the POM file
* @return the parsed Document
* @throws IOException if there's an error reading the file
* @throws DomTripException if there's an error parsing the XMLView on GitHub (pinned to e4093d4e12)
Solutions
- `cd` into the directory that actually contains pom.xml and rerun.
- If the tool accepts a path, point it at the POM-containing directory.
- Confirm the checkout has a POM: `ls pom.xml`, or find it: `find . -maxdepth 2 -name pom.xml`.
- For nested layouts, start at the aggregator POM's directory.
Example fix
# before: repo root has no pom.xml (it is in app/) $ cd ~/src/myrepo && mvn up # after $ cd ~/src/myrepo/app && mvn up
Defensive patterns
Strategy: validation
Validate before calling
if (!Files.isRegularFile(startDirectory.resolve("pom.xml"))) {
throw new IllegalArgumentException("Not a Maven project root (no pom.xml): " + startDirectory);
}
Map<Path, Document> poms = PomDiscovery.discoverPoms(startDirectory); Prevention
- Locate the aggregator POM first (`find . -maxdepth 2 -name pom.xml`) and run from its directory.
- Fail fast in scripts on missing pom.xml before invoking the upgrade tool.
When it happens
Trigger: Running the upgrade tool from a subdirectory that has no pom.xml, from the parent of the checkout, or from a scratch folder; a fresh clone whose aggregator POM sits in a nested directory.
Common situations: Nested project layouts (project/app/pom.xml while running at project/); monorepo checkouts with multiple roots; typos in a path argument; generated projects where the POM is created later.
Related errors
- POM file {} specified with the -f/--file command line argume
- Repository list contains duplicate entries. Each repository
- Repository list contains null entries. All repository entrie
- System artifact: {} has no file attached
- System artifact: {} not found in path: {}
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/1f743b30bfd04289.
Report an issue: GitHub.