I tried to do mvn install
on my Maven project. But I get the error:
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:3.1.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:3.1.0: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:3.1.0 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/3.1.0/maven-clean-plugin-3.1.0.pom ProxyInfo{host='MYCOMPANYPROXYHOST', userName='null', port=8080, type='https', nonProxyHosts='null'}: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
I get an error telling me that Maven couldn't find the certificate, I searched almost every website to find a solution.
What I have tried :
I changed the Maven settings file, my 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>
I went to https://repo.maven.apache.org/maven2 and downloaded the certificate, then I added it to the cacerts, with the command:
keytool -import -alias example -keystore .\cacerts -file example.cer
Details :
- The cacerts file is in
%JAVA_HOME%\lib\security
. - I could obviously go to https://repo.maven.apache.org/maven2 on my Web Browser, since I've downloaded the certificate.
- I am on Windows 10, 64 bits
EDIT:
The command mvn -version show
gives:
Picked up JAVA_TOOL_OPTIONS: -Djava.vendor="Sun Microsystems inc."
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Users\MYUSER\Desktop\Code\apache-maven-3.6.3\bin\..
Java version: 1.8.0_73, vendor: Sun Microsystems inc., runtime: C:\Users\MYUSER\Desktop\TEST\05-Environnement_dev\Tools\Java\jdk-8u73-windows-x64\jre
Default locale: fr_FR, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
EDIT 2:
I tried to use Eclipse, instead of the Maven command. And I could verify this:
When I change the username or the password I get the error Failed to authenticate with proxy
, and modifying the proxy host changes the error message. I can now guarantee that the proxy settings are correct.
(This step actually has cost me half an hour with the IT service, because I failed to authenticate with the proxy multiple times).