apache/maven · error · MissingProjectException
The goal you specified requires a project to execute but the
Error message
The goal you specified requires a project to execute but there is no POM in this directory ({}). Please verify you invoked Maven from the correct directory. What it means
DefaultLifecycleStarter.execute() throws MissingProjectException before any task calculation when the requested tasks require a project but session.getRequest().isProjectPresent() is false — i.e., Maven was started in a directory containing no pom.xml (and none supplied with -f/-p). The directory printed is the execution root directory.
Source
Thrown at impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleStarter.java:86
this.eventCatapult = eventCatapult;
this.defaultLifeCycles = defaultLifeCycles;
this.buildListCalculator = buildListCalculator;
this.lifecycleDebugLogger = lifecycleDebugLogger;
this.lifecycleTaskSegmentCalculator = lifecycleTaskSegmentCalculator;
this.builders = builders;
}
@Override
public void execute(MavenSession session) {
eventCatapult.fire(ExecutionEvent.Type.SessionStarted, session, null);
ReactorContext reactorContext = null;
ProjectBuildList projectBuilds = null;
MavenExecutionResult result = session.getResult();
try {
if (buildExecutionRequiresProject(session) && projectIsNotPresent(session)) {
throw new MissingProjectException("The goal you specified requires a project to execute"
+ " but there is no POM in this directory (" + session.getExecutionRootDirectory() + ")."
+ " Please verify you invoked Maven from the correct directory.");
}
List<TaskSegment> taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments(session);
projectBuilds = buildListCalculator.calculateProjectBuilds(session, taskSegments);
if (projectBuilds.isEmpty()) {
throw new NoGoalSpecifiedException("No goals have been specified for this build."
+ " You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or"
+ " <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>."
+ " Available lifecycle phases are: " + defaultLifeCycles.getLifecyclePhaseList() + ".");
}
if (logger.isDebugEnabled()) {
lifecycleDebugLogger.debugReactorPlan(projectBuilds);
}
View on GitHub (pinned to e4093d4e12)
Solutions
- cd into the directory that contains pom.xml and re-run
- Or point Maven at the POM explicitly: mvn -f /path/to/project/pom.xml package
- If the goal genuinely needs no project (e.g. archetype:generate from scratch), verify its name — most core phases do require one
- In CI, assert the POM exists before invoking Maven
Example fix
# before cd /tmp && mvn package # no pom.xml in /tmp # after cd /path/to/project && mvn package # or: mvn -f /path/to/project/pom.xml package
Defensive patterns
Strategy: validation
Validate before calling
// guard scripts/embedders before invoking
if (!Files.exists(rootDir.resolve("pom.xml"))) {
throw new IllegalStateException("No pom.xml in " + rootDir + " - cd or use -f");
} Try / catch
catch (MissingProjectException e) {
// message names the offending directory; switch cwd or add -f and retry
} Prevention
- Always invoke Maven with an explicit -f path in CI scripts
- Assert pom.xml existence in pipeline pre-steps
- Set projectless goals apart from project builds in scripts
When it happens
Trigger: Running 'mvn package' (or any project-requiring goal) in a folder without a pom.xml; running from a parent folder assuming the reactor will find child POMs; -f pointing at a directory or file that does not exist so no project got loaded.
Common situations: Wrong terminal/cwd when launching Maven; CI checking out a subdirectory but running the build from the workspace root; scripts run in $HOME or /tmp; POM named something other than pom.xml without -f.
Related errors
- The goal you specified requires a project to execute but the
- Unbounded range: {}
- Ranges overlap: {}
- Range defies version ordering: {}
- -D%s system property is not set.
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/b71a4f4272b2cd7f.
Report an issue: GitHub.