{"record":{"id":"d0bccaac1c27c24d","repo":"apache/maven","slug":"unable-to-lookup-lifecycles-from-the-plexus-contai","errorCode":null,"errorMessage":"Unable to lookup lifecycles from the plexus container","messagePattern":"Unable to lookup lifecycles from the plexus container","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java","lineNumber":180,"sourceCode":"                .peek(l -> Objects.requireNonNull(l.getId(), \"A lifecycle must have an id.\"))\n                .sorted(Comparator.comparing(Lifecycle::getId, comparator))\n                .collect(Collectors.toList());\n    }\n\n    private Map<String, Lifecycle> lookupLifecycles() {\n        // TODO: Remove the following code when maven-compat is gone\n        // This code is here to ensure maven-compat's EmptyLifecycleExecutor keeps on working.\n        if (lookup == null) {\n            return customLifecycles != null ? customLifecycles : new HashMap<>();\n        }\n\n        // Lifecycles cannot be cached as extensions might add custom lifecycles later in the execution.\n        try {\n            return registry != null\n                    ? registry.stream().collect(Collectors.toMap(lf -> lf.id(), lf -> new Lifecycle(registry, lf)))\n                    : Map.of();\n        } catch (LookupException e) {\n            throw new IllegalStateException(\"Unable to lookup lifecycles from the plexus container\", e);\n        }\n    }\n\n    public String getLifecyclePhaseList() {\n        return getLifeCycles().stream().flatMap(l -> l.getPhases().stream()).collect(Collectors.joining(\", \"));\n    }\n}\n","sourceCodeStart":162,"sourceCodeEnd":188,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java#L162-L188","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run with -e (and -X if needed) to inspect the nested LookupException cause — it names the component that failed","Check for duplicated/conflicting Maven artifact versions on the classpath (mvn dependency:tree on your distribution or extension)","Remove recently added extensions one by one to find which one breaks container wiring","If embedding, ensure the container is created via the standard MavenGuiceModule/Sisu setup rather than ad-hoc component registration"],"exampleFix":"# before\ndistribution with extension pulling maven-core:4.0.0-rc + maven-lifecycle:3.9 -> IllegalStateException\n\n# after\n# align all maven-* artifacts to the same version in the extension's dependencies\n<dependency>\n  <groupId>org.apache.maven</groupId>\n  <artifactId>maven-core</artifactId>\n  <version>${maven.version}</version>\n  <scope>provided</scope>\n</dependency>","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"Unable to lookup lifecycles\") && e.getCause() instanceof LookupException le) {\n        // inspect le for the failing component; fix classpath/extension conflicts, then restart\n    }\n}","preventionTips":["Pin all maven-* artifacts to one version in custom distributions and extensions","Test custom extensions against the exact Maven version used in CI","Avoid hand-building the Plexus container; use the standard Maven embedder setup"],"tags":["maven","plexus","sisu","container-wiring","extension"],"backgroundTag":"component-lookup-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}