quarkusio/quarkus · error · RuntimeException

Failed to initialize Maven model resolver

Error message

Failed to initialize Maven model resolver

What it means

DefaultEffectiveModelResolver wraps a Maven resolver to build effective (interpolated, parent-merged) POM models. This RuntimeException is thrown in the constructor when creating the BootstrapModelCache from the repository system session fails with a BootstrapMavenException, meaning the resolver cannot even be constructed.

Source

Thrown at independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/DefaultEffectiveModelResolver.java:41

import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject;
import io.quarkus.bootstrap.resolver.maven.workspace.LocalWorkspace;
import io.quarkus.bootstrap.resolver.maven.workspace.ModelUtils;
import io.quarkus.maven.dependency.ArtifactCoords;

class DefaultEffectiveModelResolver implements EffectiveModelResolver {

    private final MavenArtifactResolver resolver;
    private final ModelBuilder modelBuilder;
    private final ModelCache modelCache;
    private final Map<ArtifactCoords, Model> effectiveModels = new HashMap<>();

    DefaultEffectiveModelResolver(MavenArtifactResolver resolver) {
        this.resolver = resolver;
        try {
            modelCache = new BootstrapModelCache(resolver.getMavenContext().getRepositorySystemSession());
        } catch (BootstrapMavenException e) {
            throw new RuntimeException("Failed to initialize Maven model resolver", e);
        }
        modelBuilder = BootstrapModelBuilderFactory.getDefaultModelBuilder();
    }

    public Model resolveEffectiveModel(ArtifactCoords coords) {
        return resolveEffectiveModel(coords, List.of());
    }

    public Model resolveEffectiveModel(ArtifactCoords coords, List<RemoteRepository> repos) {

        if (!ArtifactCoords.TYPE_POM.equals(coords.getType())) {
            coords = ArtifactCoords.pom(coords.getGroupId(), coords.getArtifactId(), coords.getVersion());
        }

        var cached = effectiveModels.get(coords);
        if (cached != null) {
            return cached;
        }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Fix errors in ~/.m2/.mvn/settings.xml (validate XML, repository and mirror definitions)
  2. Verify the local Maven repository path is writable and valid
  3. Run with -X / enable Maven debugging to see the underlying BootstrapMavenException cause
  4. Rebuild the MavenArtifactResolver with a known-good MavenContext before constructing this class

Example fix

// before
DefaultEffectiveModelResolver r = new DefaultEffectiveModelResolver(badResolver);
// after
MavenArtifactResolver resolver = new MavenArtifactResolver(new MavenContextBuilder()
    .setLocalRepository(Paths.get("~/.m2/repository").toAbsolutePath())
    .setSettings(Paths.get("~/.m2/settings.xml")).build());
DefaultEffectiveModelResolver r = new DefaultEffectiveModelResolver(resolver);
Defensive patterns

Strategy: try-catch

Validate before calling

// validate settings before creating resolver
Path settings = Paths.get(System.getProperty("user.home"), ".m2", "settings.xml");
if (java.nio.file.Files.exists(settings)) {
    try { javax.xml.XMLConstants.class.getName(); new javax.xml.parsers.DocumentBuilderFactory().newDocumentBuilder().parse(settings.toFile()); }
    catch (Exception e) { throw new IllegalStateException("Invalid settings.xml", e); }
}

Try / catch

try {
    DefaultEffectiveModelResolver r = new DefaultEffectiveModelResolver(resolver);
} catch (RuntimeException e) {
    logger.error("Model resolver init failed; check settings.xml/local repo", e);
    throw new IllegalStateException("Invalid Maven configuration: " + e.getCause(), e);
}

Prevention

When it happens

Trigger: Calling new DefaultEffectiveModelResolver(resolver) where resolver.getMavenContext().getRepositorySystemSession() is misconfigured or BootstrapModelCache construction throws BootstrapMavenException (e.g. invalid Maven context/session setup).

Common situations: Broken ~/.m2/settings.xml (malformed XML, unresolvable mirrors), invalid localRepository path, or a MavenArtifactResolver built with bad configuration passed into application/model resolution APIs.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/b07e6fa66116acb8. Report an issue: GitHub.