apache/maven · error · IllegalStateException

Unable to lookup lifecycles from the plexus container

Error message

Unable to lookup lifecycles from the plexus container

What it means

DefaultLifecycles.getLifeCycles() streams the injected Lifecycle registry (ServiceLocator lookup of all Lifecycle components) and wraps any LookupException in an IllegalStateException. Failure means the Plexus/Sisu container could not deliver lifecycle components — a container wiring problem, not a user POM problem.

Source

Thrown at impl/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java:180

                .peek(l -> Objects.requireNonNull(l.getId(), "A lifecycle must have an id."))
                .sorted(Comparator.comparing(Lifecycle::getId, comparator))
                .collect(Collectors.toList());
    }

    private Map<String, Lifecycle> lookupLifecycles() {
        // TODO: Remove the following code when maven-compat is gone
        // This code is here to ensure maven-compat's EmptyLifecycleExecutor keeps on working.
        if (lookup == null) {
            return customLifecycles != null ? customLifecycles : new HashMap<>();
        }

        // Lifecycles cannot be cached as extensions might add custom lifecycles later in the execution.
        try {
            return registry != null
                    ? registry.stream().collect(Collectors.toMap(lf -> lf.id(), lf -> new Lifecycle(registry, lf)))
                    : Map.of();
        } catch (LookupException e) {
            throw new IllegalStateException("Unable to lookup lifecycles from the plexus container", e);
        }
    }

    public String getLifecyclePhaseList() {
        return getLifeCycles().stream().flatMap(l -> l.getPhases().stream()).collect(Collectors.joining(", "));
    }
}

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Run with -e (and -X if needed) to inspect the nested LookupException cause — it names the component that failed
  2. Check for duplicated/conflicting Maven artifact versions on the classpath (mvn dependency:tree on your distribution or extension)
  3. Remove recently added extensions one by one to find which one breaks container wiring
  4. If embedding, ensure the container is created via the standard MavenGuiceModule/Sisu setup rather than ad-hoc component registration

Example fix

# before
distribution with extension pulling maven-core:4.0.0-rc + maven-lifecycle:3.9 -> IllegalStateException

# after
# align all maven-* artifacts to the same version in the extension's dependencies
<dependency>
  <groupId>org.apache.maven</groupId>
  <artifactId>maven-core</artifactId>
  <version>${maven.version}</version>
  <scope>provided</scope>
</dependency>
Defensive patterns

Strategy: try-catch

Try / catch

catch (IllegalStateException e) {
    if (e.getMessage().contains("Unable to lookup lifecycles") && e.getCause() instanceof LookupException le) {
        // inspect le for the failing component; fix classpath/extension conflicts, then restart
    }
}

Prevention

When it happens

Trigger: The registry.stream() collection throws LookupException when a registered Lifecycle component cannot be instantiated/resolved — e.g. an extension adds a lifecycle descriptor whose dependencies are missing from the plugin classpath, classpath conflicts (duplicate maven-core versions), or a custom embedder whose container was populated with incompatible component versions.

Common situations: Running Maven with an extension or custom distribution that ships mismatched maven-core/maven-lifecycle artifacts; embedders constructing the Plexus container by hand and forgetting lifecycle module components; NoClassDefFoundError inside component instantiation surfacing as LookupException.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/d0bccaac1c27c24d. Report an issue: GitHub.