{"record":{"id":"63ed34775d850a25","repo":"apache/maven","slug":"unable-to-resolve-version","errorCode":null,"errorMessage":"Unable to resolve version","messagePattern":"Unable to resolve version","errorType":"exception","errorClass":"VersionResolverException","httpStatus":null,"severity":"error","filePath":"impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultVersionResolver.java","lineNumber":101,"sourceCode":"                @Override\n                public Version getVersion() {\n                    return session.parseVersion(res.getVersion());\n                }\n\n                @Override\n                public Optional<Repository> getRepository() {\n                    if (res.getRepository() instanceof org.eclipse.aether.repository.LocalRepository localRepository) {\n                        return Optional.of(new DefaultLocalRepository(localRepository));\n                    } else if (res.getRepository()\n                            instanceof org.eclipse.aether.repository.RemoteRepository remoteRepository) {\n                        return Optional.of(new DefaultRemoteRepository(remoteRepository));\n                    } else {\n                        return Optional.empty();\n                    }\n                }\n            };\n        } catch (VersionResolutionException e) {\n            throw new VersionResolverException(\"Unable to resolve version\", e);\n        } finally {\n            RequestTraceHelper.exit(trace);\n        }\n    }\n}\n","sourceCodeStart":83,"sourceCodeEnd":107,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultVersionResolver.java#L83-L107","documentation":"DefaultVersionResolver wraps the resolver's VersionResolutionException in VersionResolverException(\"Unable to resolve version\"). This path resolves meta-versions — RELEASE, LATEST, and snapshot variants — from maven-metadata.xml in the local and remote repositories; it fails when that metadata is missing, unreadable, or does not contain a usable entry for the artifact.","triggerScenarios":"versionResolver.resolve(session, request) for a dependency versioned 'RELEASE' or 'LATEST' when no repository (including the local cache) can serve maven-metadata.xml for the artifact; resolving an unresolvable SNAPSHOT whose metadata is absent or corrupted.","commonSituations":"Poms still using RELEASE/LATEST (deprecated since Maven 3 and rejected by many builds); interrupted downloads leaving truncated metadata in ~/.m2/repository; a remote repository that does not generate metadata; relocated artifacts behind mirrors.","solutions":["Pin an explicit version instead of RELEASE/LATEST — the supported and reproducible practice","Delete the corrupted local metadata for that groupId/artifactId under ~/.m2/repository and retry so it is re-fetched","Confirm the remote repository actually publishes maven-metadata.xml for the artifact and that mirrors/proxies pass it through"],"exampleFix":"<!-- before -->\n<dependency>\n  <groupId>com.acme</groupId>\n  <artifactId>api</artifactId>\n  <version>RELEASE</version>\n</dependency>\n\n<!-- after -->\n<dependency>\n  <groupId>com.acme</groupId>\n  <artifactId>api</artifactId>\n  <version>1.4.2</version>\n</dependency>","handlingStrategy":"try-catch","validationCode":"// avoid meta-versions entirely; verify a concrete version exists in metadata before resolving\nString version = \"1.4.2\";\nif (\"RELEASE\".equals(version) || \"LATEST\".equals(version)) {\n    throw new IllegalArgumentException(\"Meta-version '\" + version + \"' is not supported; pin an explicit version\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    VersionResult r = versionResolver.resolve(session, request);\n} catch (VersionResolverException e) {\n    if (e.getCause() instanceof org.eclipse.aether.resolution.VersionResolutionException vr) {\n        // metadata missing/corrupt: purge local copy and retry once with a pinned version\n        purgeLocalMetadata(request.artifact());\n        return versionResolver.resolve(session, withPinnedVersion(request, \"1.4.2\"));\n    }\n    throw e;\n}","preventionTips":["Never depend on RELEASE/LATEST; pin explicit versions (also required for reproducible builds)","After interrupted builds, delete the affected maven-metadata-*.xml files under ~/.m2/repository","Confirm remote repositories publish metadata for the artifacts you consume"],"tags":["maven","resolver","versioning","metadata","release-latest"],"backgroundTag":"version-resolution-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}