apache/maven · error · RuntimeException

Unable to create repository

Error message

Unable to create repository

What it means

RuntimeException from DefaultSession.toArtifactRepository: converting an API RemoteRepository to the legacy ArtifactRepository via mavenRepositorySystem.createRepository(url, id, releasesEnabled, releasesPolicy, snapshotsEnabled, snapshotsPolicy, checksumPolicy) threw. Failures such as a malformed URL that cannot be turned into a repository are wrapped with this generic message. Note the sibling branch: a repository that is not a DefaultRemoteRepository hits UnsupportedOperationException('Not yet implemented') instead.

Source

Thrown at impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultSession.java:236

    }

    @Override
    public ArtifactRepository toArtifactRepository(RemoteRepository repository) {
        if (repository instanceof DefaultRemoteRepository defaultRemoteRepository) {
            org.eclipse.aether.repository.RemoteRepository rr = defaultRemoteRepository.getRepository();

            try {
                return mavenRepositorySystem.createRepository(
                        rr.getUrl(),
                        rr.getId(),
                        rr.getPolicy(false).isEnabled(),
                        rr.getPolicy(false).getUpdatePolicy(),
                        rr.getPolicy(true).isEnabled(),
                        rr.getPolicy(true).getUpdatePolicy(),
                        rr.getPolicy(false).getChecksumPolicy());

            } catch (Exception e) {
                throw new RuntimeException("Unable to create repository", e);
            }
        } else {
            // TODO
            throw new UnsupportedOperationException("Not yet implemented");
        }
    }
}

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Fix the repository URL to a full URI with scheme: https://host/path
  2. Find the offending entry: mvn help:effective-pom / help:effective-settings and grep the printed repository URLs
  3. If a custom RemoteRepository implementation triggers the 'Not yet implemented' branch, pass repositories obtained from the session instead of hand-built ones

Example fix

<!-- before -->
<repository>
  <id>corp</id>
  <url>http//repo.corp/maven</url>
</repository>

<!-- after -->
<repository>
  <id>corp</id>
  <url>https://repo.corp/maven</url>
</repository>
Defensive patterns

Strategy: validation

Validate before calling

// Validate every repository URL before it reaches the session
for (RemoteRepository rr : repositories) {
    try {
        URI uri = URI.create(rr.getUrl());
        if (uri.getScheme() == null || uri.getHost() == null) throw new IllegalArgumentException(rr.getUrl());
    } catch (IllegalArgumentException bad) {
        throw new IllegalStateException("Repository '" + rr.getId() + "' has invalid URL: " + rr.getUrl(), bad);
    }
}

Prevention

When it happens

Trigger: Session.toArtifactRepository / toArtifactRepositories on a DefaultRemoteRepository whose URL cannot be interpreted by MavenRepositorySystem.createRepository — missing scheme, typo like 'http//host', or illegal characters — or whose policy values are invalid.

Common situations: Malformed <url> entries in a pom's <repositories> or <distributionManagement>, in settings.xml mirrors or profiles; copy-paste errors dropping '://'; migrating http URLs truncated by tooling.

Related errors


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