quarkusio/quarkus · error · RuntimeException

Failed to initialize model resolver

Error message

Failed to initialize model resolver

What it means

Thrown when BootstrapModelResolver.newInstance(mavenContext, null) fails with BootstrapMavenException while creating the model resolver used to resolve parent POMs and imported BOMs during model building.

Source

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

            pomResult = resolver.resolve(new DefaultArtifact(coords.getGroupId(), coords.getArtifactId(),
                    coords.getClassifier(), coords.getType(), coords.getVersion()), repos);
            pomFile = pomResult.getArtifact().getFile();
        } catch (BootstrapMavenException e) {
            throw new RuntimeException("Failed to resolve " + coords.toCompactCoords(), e);
        }

        final Model rawModel;
        try {
            rawModel = ModelUtils.readModel(pomFile.toPath());
        } catch (IOException e1) {
            throw new RuntimeException("Failed to read " + pomFile, e1);
        }

        final ModelResolver modelResolver;
        try {
            modelResolver = BootstrapModelResolver.newInstance(resolver.getMavenContext(), null);
        } catch (BootstrapMavenException e) {
            throw new RuntimeException("Failed to initialize model resolver", e);
        }

        // override the relative path to the parent in case it's in the local Maven repo
        Parent parent = rawModel.getParent();
        if (parent != null) {
            final Artifact parentPom = new DefaultArtifact(parent.getGroupId(), parent.getArtifactId(),
                    ArtifactCoords.TYPE_POM, parent.getVersion());
            final ArtifactResult parentResult;
            final Path parentPomPath;
            try {
                parentResult = resolver.resolve(parentPom, repos);
                parentPomPath = parentResult.getArtifact().getFile().toPath();
            } catch (BootstrapMavenException e) {
                throw new RuntimeException("Failed to resolve " + parentPom, e);
            }
            try {
                rawModel.getParent()
                        .setRelativePath(pomFile.toPath().getParent().relativize(parentPomPath).toString());

View on GitHub (pinned to e1c734241f)

Solutions

  1. Validate the MavenContext/settings used to build the MavenArtifactResolver
  2. Check that all resolver dependencies (maven-resolver, plexus-utils) are on the classpath at the expected versions
  3. Inspect the BootstrapMavenException cause chain for the concrete misconfiguration
  4. Recreate MavenArtifactResolver with default detection (let it discover settings.xml itself)
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure context is functional before model building
Objects.requireNonNull(resolver.getMavenContext(), "MavenContext must be set");
Objects.requireNonNull(resolver.getMavenContext().getRepositorySystemSession(), "RepositorySystemSession must be set");

Try / catch

try {
    Model m = modelResolver.resolveEffectiveModel(coords);
} catch (RuntimeException e) {
    throw new IllegalStateException("Model resolver init failed: " + e.getMessage(), e.getCause());
}

Prevention

When it happens

Trigger: resolveEffectiveModel(...) reaching the modelResolver setup when the MavenContext is invalid (bad session/settings/workspace reader configuration).

Common situations: Same root causes as resolver initialization failures: invalid settings.xml, broken Maven context built programmatically, classpath missing required resolver components.

Related errors


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