apache/maven · error · UnsupportedOperationException
Not implemented yet
Error message
Not implemented yet
What it means
Session.toRepository(RemoteRepository) converts a Maven API RemoteRepository to the Eclipse Resolver type by casting to the internal DefaultRemoteRepository and unwrapping the delegate. The Maven API interfaces are not currently open for user implementations, so any non-DefaultRemoteRepository instance cannot be converted and throws UnsupportedOperationException marked with a TODO. The same applies to other toXxx converters: only session-produced default implementations are convertible.
Source
Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/AbstractSession.java:297
@Override
public List<org.eclipse.aether.repository.RemoteRepository> toRepositories(List<RemoteRepository> repositories) {
return repositories == null ? null : map(repositories, this::toRepository);
}
@Override
public List<org.eclipse.aether.repository.RemoteRepository> toResolvingRepositories(
List<RemoteRepository> repositories) {
return getRepositorySystem().newResolutionRepositories(getSession(), toRepositories(repositories));
}
@Override
public org.eclipse.aether.repository.RemoteRepository toRepository(RemoteRepository repository) {
if (repository instanceof DefaultRemoteRepository defaultRemoteRepository) {
return defaultRemoteRepository.getRepository();
} else {
// TODO
throw new UnsupportedOperationException("Not implemented yet");
}
}
@Override
public org.eclipse.aether.repository.LocalRepository toRepository(LocalRepository repository) {
if (repository instanceof DefaultLocalRepository defaultLocalRepository) {
return defaultLocalRepository.getRepository();
} else {
// TODO
throw new UnsupportedOperationException("Not implemented yet");
}
}
@Override
public List<org.eclipse.aether.graph.Dependency> toDependencies(
Collection<DependencyCoordinates> dependencies, boolean managed) {
return dependencies == null ? null : map(dependencies, d -> toDependency(d, managed));
}View on GitHub (pinned to e4093d4e12)
Solutions
- Create repositories through the session API: session.createRemoteRepository(...) so you get a DefaultRemoteRepository the session can convert
- If you need custom repository behavior, wrap at the resolver level (RepositorySystemSession config) rather than the Maven API level
- In tests, mock the Session or use the standalone session factory instead of hand-implemented repository records
Example fix
// before
RemoteRepository repo = new MyRemoteRepository('central', 'https://repo.maven.apache.org/maven2');
List<org.eclipse.aether.repository.RemoteRepository> repos = session.toRepositories(List.of(repo)); // throws
// after
RemoteRepository repo = session.createRemoteRepository('central', 'https://repo.maven.apache.org/maven2', 'default');
List<org.eclipse.aether.repository.RemoteRepository> repos = session.toRepositories(List.of(repo)); Defensive patterns
Strategy: type-guard
Validate before calling
if (!(remoteRepo instanceof DefaultRemoteRepository)) {
throw new IllegalArgumentException('RemoteRepository must be created by the session');
} Type guard
static boolean isConvertible(RemoteRepository r) { return r instanceof DefaultRemoteRepository; } Prevention
- Always create remote repositories via session.createRemoteRepository(...)
- Do not implement org.apache.maven.api interfaces yourself
- In tests, mock the Session rather than hand-rolling repository records
When it happens
Trigger: Implementing org.apache.maven.api.RemoteRepository yourself (or obtaining one from another framework) and passing it to session.toRepository(...), toResolvingRepositories(...), or any API (e.g. ArtifactResolverRequest/ArtifactDeployerRequest) that internally converts repositories via the session.
Common situations: Custom repository wrappers or mocks in tests that implement the RemoteRepository interface instead of building one through Session.createRemoteRepository(...); library code written against the interfaces assuming they are implementable.
Related errors
- Unable to get dependency information: " + e.getMessage()
- Unable to get dependency information for " + artifact.getId(
- Invalid request
- Unable to build project
- Cannot attach artifact to project: groupId, artifactId and v
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/5a5f5486f4e4c0e5.
Report an issue: GitHub.