I am trying to compile my code using maven, getting below error,
i am using azure devops server and using build pipeline Maven Errror Could not transfer artifact org.apache.maven.plugins:maven-source-plugin:pom:3.0.1 from/to central
2021-02-26T11:43:14.4764714Z [ERROR] Plugin org.apache.maven.plugins:maven-source-plugin:3.0.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-source-plugin:jar:3.0.1: Could not transfer artifact org.apache.maven.plugins:maven-source-plugin:pom:3.0.1 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-source-plugin/3.0.1/maven-source-plugin-3.0.1.pom ProxyInfo{host='12.3.4.59', userName='null', port=80, type='http', nonProxyHosts='null'}: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
According to the error message:
Transfer failed for https://repo.maven.apache.org/maven2...unable to find valid certification path to requested target
It shows the Maven is trying to download an indirect dependency from Maven Central Repository located at https://repo.maven.apache.org/maven
2, which is a secured HTTP server (HTTPS). So the issue may comes from your certificate itself or your network.
For the certificate, try to https://repo.maven.apache.org/maven2
and downloaded the certificate, then added it to the cacerts, with the command:
keytool -import -alias example -keystore .\cacerts -file example.cer
Please try to check more info from this thread "PKIX path building failed" and "unable to find valid certification path to requested target"
For the network, please try to access that very URL on you browser and check if it's operational. If you really can't access the Maven Central Repo with HTTPS from your browser, maybe it's becouse you are behind some proxy rule that is keeping you from download the server certificate.
You could set the settings.xml file is like below:
<proxies>
<proxy>
<active>true</active>
<protocol>https</protocol>
<host>MY_COMPANY_HOST</host>
<port>8080</port>
<username>MY_USERNAME</username>
<password>MY_PASSWORD</password>
<nonProxyHosts>localhost</nonProxyHosts>
</proxy>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>MY_COMPANY_HOST</host>
<port>8080</port>
<username>MY_USERNAME</username>
<password>MY_PASSWORD</password>
<nonProxyHosts>localhost</nonProxyHosts>
</proxy>
</proxies>
And check the thread Problems using Maven and SSL behind proxy for some more details.