Issue
I have been facing this annoying issue of certificate during mvn clean install
execution.
PS C:\Users\milan\service> mvn clean install
[INFO] Scanning for projects...
Downloading from spring-milestones: https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-parent/2.2.0.M6/spring-boot-starter-parent-2.2.0.M6.pom
Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.2.0.M6/spring-boot-starter-parent-2.2.0.M6.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.demo.microservices:service:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.2.0.M6 from/to spring-milestones (https://repo.spring.io/milestone): transfer failed for https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-parent/2.2.0.M6/spring-boot-starter-parent-2.2.0.M6.pom and 'parent.relativePath' points at no local POM @ line 4, column 11
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.demo.microservices:service:0.0.1-SNAPSHOT (C:\Users\milan\service\pom.xml) has 1 error
[ERROR] Non-resolvable parent POM for com.demo.microservices:service:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.2.0.M6 from/to spring-milestones (https://repo.spring.io/milestone): transfer failed for https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-parent/2.2.0.M6/spring-boot-starter-parent-2.2.0.M6.pom and 'parent.relativePath' points at no local POM @ line 4, column 11: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
I have found solution which is working fine.
- The way it works now is I have to vising (i.e. https://repo.spring.io/milestone or https://repo.maven.apache.org/maven2/) the site mention in error via browser and then have to export certificate from there (as shown in image below) and load into
lib\security\cacert
usingkeytool
every time I get this `PKIX build errors. - Some times I have to visit the same site again https://repo.maven.apache.org/maven2/ and need to redownload the certificate and insert into
lib\security\cacert
usingkeytool
as described in solution.
Is there any solution, That can resolve this issue once and for all ?
System :
Apache Maven 3.8.4
Maven home: C:\apache-maven-3.8.4
Java version: 17.0.1, vendor: Eclipse Adoptium, runtime: C:\Program Files\Eclipse Adoptium\jdk-17.0.1.12-hotspot
Default locale: en_IN, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Solution
I am able to resolve this issue by replacing the cacert
file. To be more precise I have replace cacert
of Eclipse Adoptium\jdk-17.0.1.12-hotspot
with Eclipse Adoptium\jre-8.0.312.7-hotspot
to fix it.
Things to my surprises is that, After replacing new cacaert file I did not had to use keytool to load certificate manually. It's still mystery why old cacert file was causing trouble.
NOTE: Take backup of original cacert file before you replace with new one.
try this solution if still not resolved.
Answered By - Milan
Answer Checked By - David Goodson (JavaFixing Volunteer)