apache/maven · error · InvalidRepositoryException
URL missing for repository " + id
Error message
URL missing for repository " + id
What it means
Thrown by LegacyRepositorySystem.buildArtifactRepository(Repository) when a repository definition has a valid id but its url is null or empty. Without a URL Maven cannot compute the artifact request paths for the repository, so the model is rejected with InvalidRepositoryException("URL missing for repository <id>"). The offending repository id is attached to the exception for diagnostics.
Source
Thrown at compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java:698
}
}
//
// Artifact Repository Creation
//
@Override
public ArtifactRepository buildArtifactRepository(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());
return createArtifactRepository(id, url, getLayout(repo.getLayout()), snapshots, releases);
} else {
return null;
}
}
private ArtifactRepository createRepository(
String url,
String repositoryId,
boolean releases,
String releaseUpdates,
boolean snapshots,View on GitHub (pinned to e4093d4e12)
Solutions
- Add the <url> element to the repository whose id appears in the message
- If the URL uses a property placeholder, verify the property is defined in the same POM, a loaded profile, or settings.xml and resolves non-empty for the active profile
- Run mvn help:effective-pom -Dverbose to see the final resolved repository URLs
- When building the model in code, call repository.setUrl(...) before buildArtifactRepository
Example fix
<!-- before -->
<repository>
<id>example</id>
<url>${example.repo.url}</url> <!-- property never defined -->
</repository>
<!-- after -->
<properties>
<example.repo.url>https://repo.example.com/maven</example.repo.url>
</properties>
<repository>
<id>example</id>
<url>${example.repo.url}</url>
</repository> Defensive patterns
Strategy: validation
Validate before calling
import org.apache.maven.model.Repository;
boolean hasRepositoryUrl(Repository repo) {
return repo != null
&& repo.getId() != null && !repo.getId().isEmpty()
&& repo.getUrl() != null && !repo.getUrl().isEmpty();
}
if (!hasRepositoryUrl(repo)) {
throw new IllegalArgumentException("Repository '" + repo.getId() + "' has no URL");
} Try / catch
try {
ArtifactRepository artifactRepo = legacyRepositorySystem.buildArtifactRepository(repo);
} catch (InvalidRepositoryException e) {
if (e.getMessage().startsWith("URL missing")) {
// repository id is recoverable from the message; report to the user which id lacks a URL
reportConfigError("Add <url> to repository " + repo.getId());
} else {
throw e;
}
} Prevention
- Define every repository URL property in the same POM/profile that uses it so it can never resolve empty
- Test environment-specific profiles in CI with mvn help:effective-pom to catch unresolved ${...} placeholders
- Treat repository declarations as code: review them in PRs like any other config change
When it happens
Trigger: A POM <repository>, <pluginRepository>, <distributionManagement> snapshot/release repository, or a programmatically built Repository object where getId() is non-empty but getUrl() returns null or "".
Common situations: A <repository> block where <id> is present but <url> was accidentally deleted or commented out; property placeholder for the URL resolving to nothing (e.g. <url>${repo.url}</url> with the property undefined, especially in profiles activated per-environment); code that constructs org.apache.maven.model.Repository without calling setUrl().
Understand the failure class
Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.
Related errors
- Repository identifier missing
- URL missing for repository {}
- Invalid remote repository {}
- 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/67ed38fb221c5f14.
Report an issue: GitHub.