{"record":{"id":"1f743b30bfd04289","repo":"apache/maven","slug":"no-pom-xml-found-in-directory","errorCode":null,"errorMessage":"No pom.xml found in directory: {}","messagePattern":"No pom\\.xml found in directory: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/PomDiscovery.java","lineNumber":64,"sourceCode":"    private PomDiscovery() {\n        // noop\n    }\n\n    /**\n     * Discovers and loads all POM files starting from the given directory.\n     *\n     * @param startDirectory the directory to start discovery from\n     * @return a map of Path to Document for all discovered POM files\n     * @throws IOException if there's an error reading files\n     * @throws DomTripException if there's an error parsing XML\n     */\n    public static Map<Path, Document> discoverPoms(Path startDirectory) throws IOException, DomTripException {\n        Map<Path, Document> pomMap = new HashMap<>();\n\n        // Find and load the root POM\n        Path rootPomPath = startDirectory.resolve(POM_XML);\n        if (!Files.exists(rootPomPath)) {\n            throw new IOException(\"No pom.xml found in directory: \" + startDirectory);\n        }\n\n        Document rootPom = loadPom(rootPomPath);\n        pomMap.put(rootPomPath, rootPom);\n\n        // Recursively discover modules\n        discoverModules(startDirectory, rootPom, pomMap);\n\n        return pomMap;\n    }\n\n    /**\n     * Loads a POM file as a domtrip Document.\n     *\n     * @param pomPath the path to the POM file\n     * @return the parsed Document\n     * @throws IOException if there's an error reading the file\n     * @throws DomTripException if there's an error parsing the XML","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/PomDiscovery.java#L46-L82","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before: repo root has no pom.xml (it is in app/)\n$ cd ~/src/myrepo && mvn up\n\n# after\n$ cd ~/src/myrepo/app && mvn up","handlingStrategy":"validation","validationCode":"if (!Files.isRegularFile(startDirectory.resolve(\"pom.xml\"))) {\n    throw new IllegalArgumentException(\"Not a Maven project root (no pom.xml): \" + startDirectory);\n}\nMap<Path, Document> poms = PomDiscovery.discoverPoms(startDirectory);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["maven","mvnup","pom","file-not-found"],"backgroundTag":"missing-pom-file","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}