apache/maven · error · ProjectBuildingException
Invalid remote repository {}
Error message
Invalid remote repository {} What it means
Thrown by the legacy DefaultMavenProjectBuilder while converting <repositories> declared in a POM into ArtifactRepository instances. repositorySystem.buildArtifactRepository() (followed by mirror/proxy/auth injection) throws InvalidRepositoryException when the repository definition is unusable - typically an invalid id or malformed URL - and it is rethrown as ProjectBuildingException with message 'Invalid remote repository <definition>'.
Source
Thrown at compat/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java:150
* This provides backward-compat with 2.x that allowed plugins like the maven-remote-resources-plugin:1.0 to
* populate the builder configuration with model repositories instead of artifact repositories.
*/
if (repositories != null) {
boolean normalized = false;
List<ArtifactRepository> repos = new ArrayList<>(repositories.size());
for (Object repository : repositories) {
if (repository instanceof Repository repositoryInstance) {
try {
ArtifactRepository repo = repositorySystem.buildArtifactRepository(repositoryInstance);
repositorySystem.injectMirror(request.getRepositorySession(), Arrays.asList(repo));
repositorySystem.injectProxy(request.getRepositorySession(), Arrays.asList(repo));
repositorySystem.injectAuthentication(request.getRepositorySession(), Arrays.asList(repo));
repos.add(repo);
} catch (InvalidRepositoryException e) {
throw new ProjectBuildingException("", "Invalid remote repository " + repository, e);
}
normalized = true;
} else {
repos.add((ArtifactRepository) repository);
}
}
if (normalized) {
return repos;
}
}
return (List<ArtifactRepository>) repositories;
}
private ProjectBuildingException transformError(ProjectBuildingException e) {
if (e.getCause() instanceof ModelBuildingException) {
return new InvalidProjectModelException(e.getProjectId(), e.getMessage(), e.getPomFile());View on GitHub (pinned to e4093d4e12)
Solutions
- Inspect the exact repository element echoed in the message and fix its <url> and <id> (scheme, host, path, no unresolved properties)
- Verify the URL opens outside Maven (curl) and uses a supported protocol (https/http)
- Move environment-specific repos to settings.xml profiles instead of the POM, so CI machines get correct mirrors
- If the repo sits in a parent POM you do not control, override or neutralize it in settings.xml
- Rebuild with -X to see which inject* step rejected the repository
Example fix
<!-- before -->
<repositories>
<repository>
<id>corp</id>
<url>htp://nexus.corp.example/repo</url>
</repository>
</repositories>
<!-- after -->
<repositories>
<repository>
<id>corp</id>
<url>https://nexus.corp.example/repo</url>
</repository>
</repositories> Defensive patterns
Strategy: validation
Validate before calling
// Sanity-check a repository definition before building a project with it
URI u = URI.create(repository.getUrl());
if (u.getScheme() == null || !("http".equals(u.getScheme()) || "https".equals(u.getScheme()))) {
throw new IllegalArgumentException("Unsupported repo URL: " + repository.getUrl());
} Prevention
- Keep repository URLs literal https:// in POMs; resolve properties before committing
- Centralize environment-specific repos in settings.xml profiles
- Test URLs with curl before adding them to builds
When it happens
Trigger: A POM <repositories><repository> entry with a malformed URL (wrong/unknown protocol, unparseable URI) or an otherwise invalid definition (bad id characters, unreadable layout) such that buildArtifactRepository or the inject* calls fail during project building.
Common situations: Typos in repository URLs (e.g. 'htp://', missing scheme, stray spaces or ${} left unresolved); internal Nexus/Artifactory URLs copied with placeholders; plugin/publisher POMs with exotic protocols not enabled in the resolver; corporate mirrors defined via settings.xml conflicting with POM entries.
Related errors
- URL missing for repository " + id
- URL missing for 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/e204579d2bde2eae.
Report an issue: GitHub.