{"record":{"id":"b77eca9cd8650e86","repo":"apache/maven","slug":"could-not-be-retrieved-from-repository-due","errorCode":null,"errorMessage":"{} could not be retrieved from repository: {} due to an error: {}","messagePattern":"(.+?) could not be retrieved from repository: (.+?) due to an error: (.+?)","errorType":"exception","errorClass":"RepositoryMetadataResolutionException","httpStatus":null,"severity":"error","filePath":"compat/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java","lineNumber":334,"sourceCode":"                String msg = \"Could not write fixed metadata to \" + metadataFile + \": \" + e.getMessage();\n                if (getLogger().isDebugEnabled()) {\n                    getLogger().warn(msg, e);\n                } else {\n                    getLogger().warn(msg);\n                }\n            }\n        }\n    }\n\n    @Override\n    public void resolveAlways(\n            RepositoryMetadata metadata, ArtifactRepository localRepository, ArtifactRepository remoteRepository)\n            throws RepositoryMetadataResolutionException {\n        File file;\n        try {\n            file = getArtifactMetadataFromDeploymentRepository(metadata, localRepository, remoteRepository);\n        } catch (TransferFailedException e) {\n            throw new RepositoryMetadataResolutionException(\n                    metadata + \" could not be retrieved from repository: \" + remoteRepository.getId()\n                            + \" due to an error: \" + e.getMessage(),\n                    e);\n        }\n\n        try {\n            if (file.exists()) {\n                Metadata prevMetadata = readMetadata(file);\n                metadata.setMetadata(prevMetadata);\n            }\n        } catch (RepositoryMetadataReadException e) {\n            throw new RepositoryMetadataResolutionException(e.getMessage(), e);\n        }\n    }\n\n    private File getArtifactMetadataFromDeploymentRepository(\n            ArtifactMetadata metadata, ArtifactRepository localRepo, ArtifactRepository remoteRepository)\n            throws TransferFailedException {","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java#L316-L352","documentation":"resolveAlways() downloads metadata from a remote repository via getArtifactMetadataFromDeploymentRepository(); when that transfer fails (TransferFailedException from the wagon layer) it is wrapped in RepositoryMetadataResolutionException with this message. The placeholders are the metadata being resolved, the remote repository id, and the transport error. This is a connectivity/credentials/TLS failure against the remote, not a 'metadata not found' case, which is handled separately.","triggerScenarios":"Calling resolveAlways(metadata, localRepository, remoteRepository) when the repository URL is unreachable, a proxy blocks the connection, the TLS handshake fails, or the server rejects the request with 401/403 (missing or wrong credentials for the server id).","commonSituations":"Corporate proxy or missing mirror in settings.xml; a server id in the build not matching any <server> entry in settings.xml; expired or rotated credentials against Nexus/Artifactory; repository manager down or returning 502; self-signed certificate not in the JDK truststore.","solutions":["Test the repository outside Maven: curl -I on the repository URL and on a maven-metadata.xml inside it to confirm reachability and HTTP status","Make the repository/mirror <id> match a <server> entry in settings.xml and update the credentials","Fix proxy (<proxies>) or TLS settings (truststore, javax.net.ssl.trustStore) according to the transport message","If the repository manager was restarting (transient), simply re-run the build; consider routing through an internal mirror for stability"],"exampleFix":"<!-- before: repository id 'releases' has no matching server credentials -->\n<distributionManagement>\n  <repository><id>releases</id><url>https://repo.example.com/releases</url></repository>\n</distributionManagement>\n<!-- after: add matching credentials in ~/.m2/settings.xml -->\n<servers>\n  <server>\n    <id>releases</id>\n    <username>deploy-user</username>\n    <password>${env.REPO_TOKEN}</password>\n  </server>\n</servers>","handlingStrategy":"try-catch","validationCode":"// preflight the remote repository before resolving metadata\ntry {\n    java.net.URL url = new java.net.URL(remoteRepository.getUrl());\n    java.net.HttpURLConnection c = (java.net.HttpURLConnection) url.openConnection();\n    c.setRequestMethod(\"HEAD\");\n    c.setConnectTimeout(5000);\n    int code = c.getResponseCode(); // 401/403 => fix credentials; IOException => network/proxy\n} catch (IOException e) {\n    // repository unreachable: fix network/proxy before calling resolveAlways()\n}","typeGuard":null,"tryCatchPattern":"Catch RepositoryMetadataResolutionException around resolveAlways(); inspect the cause (TransferFailedException) and branch on auth (401/403) vs connection errors; retry once for transient network failures, surface a credentials/proxy error otherwise.","preventionTips":["Keep settings.xml server ids in sync with every repository and mirror id the build uses.","Smoke-test proxy and TLS configuration per environment with curl before running builds.","Run scheduled jobs with --batch-mode and preconfigured credentials so failures are loud, not interactive hangs.","Prefer an internal mirror for both availability and consistent authentication."],"tags":["maven","metadata","network","repository","transfer","authentication"],"backgroundTag":"repository-download-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}