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
- Add a valid non-empty `<url>` to the repository whose id appears in the message.
- If the url uses ${...}, verify the property resolves in every build context (profile active, settings present, -D passed).
- 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
- Prefer literal URLs over ${...} placeholders in repository declarations.
- When placeholders are required, define them in settings.xml or always-active profiles present in CI too.
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
- URL missing for repository " + id
- Invalid remote repository {}
- Repository identifier missing
- Repository identifier missing
- Cannot find ArtifactRepositoryLayout instance for: %s %s
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/46f413b76381c632.
Report an issue: GitHub.