apache/maven · error · InvalidRepositoryException

URL missing for repository {}

Error message

URL missing for repository {}

What it means

A POM `<repository>` declaration passed id validation but its `<url>` is null or empty, so MavenRepositorySystem.buildArtifactRepository throws InvalidRepositoryException 'URL missing for repository <id>' carrying the repository id. Without a URL there is nothing to resolve from, so the declaration is rejected rather than defaulted.

Source

Thrown at impl/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java:339

    public static ArtifactRepository buildArtifactRepository(org.apache.maven.settings.Repository repo)
            throws InvalidRepositoryException {
        return buildArtifactRepository(fromSettingsRepository(repo));
    }

    public static ArtifactRepository buildArtifactRepository(org.apache.maven.model.Repository repo)
            throws InvalidRepositoryException {
        if (repo != null) {
            String id = repo.getId();

            if (id == null || id.isEmpty()) {
                throw new InvalidRepositoryException("Repository identifier missing", "");
            }

            String url = repo.getUrl();

            if (url == null || url.isEmpty()) {
                throw new InvalidRepositoryException("URL missing for repository " + id, id);
            }

            ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy(repo.getSnapshots());

            ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy(repo.getReleases());

            ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();

            return createArtifactRepository(id, url, layout, snapshots, releases);
        } else {
            return null;
        }
    }

    public static ArtifactRepositoryPolicy buildArtifactRepositoryPolicy(
            org.apache.maven.model.RepositoryPolicy policy) {
        boolean enabled = true;

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Add a valid non-empty `<url>` to the repository whose id appears in the message.
  2. If the url uses ${...}, verify the property resolves in every build context (profile active, settings present, -D passed).
  3. Delete the repository block if it is an unused leftover.

Example fix

<!-- before -->
<repository>
  <id>corp-releases</id>
</repository>

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

Strategy: validation

Validate before calling

for (org.apache.maven.model.Repository r : model.getRepositories()) {
    if (r.getUrl() == null || r.getUrl().isEmpty()) {
        throw new IllegalArgumentException("Repository " + r.getId() + " has empty <url> in " + model.getPomFile());
    }
}

Prevention

When it happens

Trigger: `<repository><id>x</id></repository>` with the url element missing or empty - frequently a `<url>${repo.url}</url>` placeholder whose property is undefined in the active profile or settings, interpolating to empty.

Common situations: Property-driven repository URLs where the property lives in an inactive profile, a private settings.xml not present in CI, or an environment-specific file that was never committed.

Related errors


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