apache/maven · critical · IllegalStateException

Unable to lookup org.eclipse.aether.RepositorySystem

Error message

Unable to lookup org.eclipse.aether.RepositorySystem

What it means

DefaultArtifactResolver obtains the Eclipse Resolver via container.lookup(RepositorySystem.class); a ComponentLookupException becomes IllegalStateException with this message (note: the cause is not even chained). It means the Maven DI container (Plexus/Sisu) has no org.eclipse.aether.RepositorySystem component registered - the runtime itself is wired incorrectly. This is an installation or embedding defect, not a project configuration problem.

Source

Thrown at compat/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java:193

        }

        if (!artifact.isResolved()) {
            ArtifactResult result;

            try {
                ArtifactRequest artifactRequest = new ArtifactRequest();
                artifactRequest.setArtifact(RepositoryUtils.toArtifact(artifact));
                artifactRequest.setRepositories(RepositoryUtils.toRepos(remoteRepositories));

                // Maven 2.x quirk: an artifact always points at the local repo, regardless whether resolved or not
                LocalRepositoryManager lrm = session.getLocalRepositoryManager();
                String path = lrm.getPathForLocalArtifact(artifactRequest.getArtifact());
                artifact.setFile(new File(lrm.getRepository().getBasedir(), path));

                RepositorySystem repoSystem = container.lookup(RepositorySystem.class);
                result = repoSystem.resolveArtifact(session, artifactRequest);
            } catch (ComponentLookupException e) {
                throw new IllegalStateException("Unable to lookup " + RepositorySystem.class.getName());
            } catch (org.eclipse.aether.resolution.ArtifactResolutionException e) {
                if (e.getCause() instanceof org.eclipse.aether.transfer.ArtifactNotFoundException) {
                    throw new ArtifactNotFoundException(e.getMessage(), artifact, remoteRepositories, e);
                } else {
                    throw new ArtifactResolutionException(e.getMessage(), artifact, remoteRepositories, e);
                }
            }

            artifact.selectVersion(result.getArtifact().getVersion());
            artifact.setFile(result.getArtifact().getFile());
            artifact.setResolved(true);

            if (artifact.isSnapshot()) {
                Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher(artifact.getVersion());
                if (matcher.matches()) {
                    Snapshot snapshot = new Snapshot();
                    snapshot.setTimestamp(matcher.group(2));
                    try {

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Replace the Maven installation with a fresh official distribution (full replacement, not file-by-file) and verify mvn -v works
  2. In embedded setups, add the complete resolver wiring: maven-resolver-provider plus sisu/plexus default containers, or bootstrap via maven-embedder's MavenCli
  3. Detect and exclude conflicting plexus-container-default / sisu versions pulled transitively by old plugins (mvn dependency:tree on the embedding project)
  4. If the local repository also corrupted core artifacts, wipe ~/.m2/repository/org/eclipse/aether and org/apache/maven so they are re-fetched

Example fix

<!-- before: only maven-compat on the classpath, no resolver wiring -->
<dependency>
  <groupId>org.apache.maven</groupId>
  <artifactId>maven-compat</artifactId>
</dependency>
<!-- after: full embedding set incl. resolver provider -->
<dependency>
  <groupId>org.apache.maven</groupId>
  <artifactId>maven-embedder</artifactId>
</dependency>
<dependency>
  <groupId>org.apache.maven.resolver</groupId>
  <artifactId>maven-resolver-provider</artifactId>
</dependency>
Defensive patterns

Strategy: try-catch

Validate before calling

try {
    container.lookup(org.eclipse.aether.RepositorySystem.class);
} catch (org.codehaus.plexus.component.repository.exception.ComponentLookupException e) {
    // container not wired for artifact resolution: fix the classpath/installation
}

Try / catch

Catch IllegalStateException with message 'Unable to lookup org.eclipse.aether.RepositorySystem' and abort: treat it as an environment failure and repair the Maven installation/embedded classpath; retrying the same call cannot succeed.

Prevention

When it happens

Trigger: Calling resolve(...) in an environment where the DI container lacks the RepositorySystem component: a corrupted Maven distribution with mixed/patched jars in MAVEN_HOME/lib, an embedded Maven classpath (maven-embedder + maven-compat) missing the resolver provider modules, or a plugin that manipulates the container and drops the component.

Common situations: Partial Maven upgrades leaving lib jars from different versions; applications embedding maven-compat without the complete Maven + Resolver component set; legacy plugins forcing an incompatible plexus-container-default onto the classpath; hand-patched maven-core jars.

Related errors


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