4

I am trying to build a proof of concept for microservices in java (eclipse) using maven Spring libraries and following this tutorial.

Below is my POM file, which shows an error, that I could not resolve:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.tutorials</groupId>
  <artifactId>HelloWorld</artifactId>
  <version>0.0.1-SNAPSHOT</version>


<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.0.RELEASE</version>
</parent>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

</project>

On the tag <parent> I have the following error:

Project build error: Non-resolvable parent POM for com.tutorials:HelloWorld:0.0.1-SNAPSHOT: Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:
 1.2.0.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has 
 elapsed or updates are forced. Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.2.0.RELEASE from/to central (https://
 repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to 
 find valid certification path to requested target and 'parent.relativePath' points at wrong local POM

How can I resolve this issue? Thanks.

Edit: In the directory User/.m2 I created a settings.xml file to overcome the proxy issue, as the following:

<settings>
  <proxies>
   <proxy>
      <id>example-proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.example.com</host>
      <port>8080</port>
      <nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
    </proxy>
  </proxies>
</settings>

Now the error is as the following:

Project build error: Non-resolvable parent POM for com.tutorials:HelloWorld:0.0.1-SNAPSHOT: Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:
 2.2.2.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has 
 elapsed or updates are forced. Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.2.2.RELEASE from/to central (https://
 repo.maven.apache.org/maven2): proxy.example.com and 'parent.relativePath' points at wrong local POM
Traveling Salesman
  • 2,209
  • 11
  • 46
  • 83
  • 3
    Are you behind a coporate proxy? – Simon Martinelli Jan 05 '20 at 09:51
  • 1
    Exactly. I am behind a corporate proxy. – Traveling Salesman Jan 05 '20 at 09:59
  • 3
    Checkout this article: https://medium.com/@petehouston/execute-maven-behind-a-corporate-proxy-network-5e08d075f744 I hope it helps – Simon Martinelli Jan 05 '20 at 10:54
  • 1
    Really a project with Spring Boot 1.X ? It's End of Life since August 2019 https://spring.io/blog/2018/07/30/spring-boot-1-x-eol-aug-1st-2019 – khmarbaise Jan 05 '20 at 15:22
  • @khmarbaise Okay now it is 2.2.2.RELEASE – Traveling Salesman Jan 06 '20 at 05:41
  • @Simon Martinelli I followed the article, now the security part of the error is gone but I am left with this error: Project build error: Non-resolvable parent POM for com.tutorials:HelloWorld:0.0.1-SNAPSHOT: Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom: 2.2.2.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, ..... Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.2.2.RELEASE from/to central (https://...): proxy.example.com and 'parent.relativePath' points at wrong local POM – Traveling Salesman Jan 06 '20 at 05:43
  • Behind a firewall/proxy configuration is not ok I suppose ... – khmarbaise Jan 06 '20 at 06:42
  • Try mvn clean install -U – Simon Martinelli Jan 06 '20 at 07:39
  • Can you access https://repo.maven.apache.org/maven2 in your browser ? Can you "curl https://repo.maven.apache.org/maven2" from your console ? Can you go in your browser to https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.2.2.RELEASE/ ? – ccc Jan 23 '20 at 23:49
  • I can access these links with my browser but eclipse seems to be blocked from doing that, it is obviously due to security reasons in my place. – Traveling Salesman Jan 26 '20 at 04:51
  • @SimonMartinelli, Traveling Salesman, one of you should post the proxy part as a solution. This has helped me. – Paul Stoner Aug 11 '21 at 16:36

1 Answers1

2

The issue is of the certificate is not installed in your java security. As you had mentioned you were able to access the https://repo.maven.apache.org/maven2/ you need to export the certificate from the site information if you were using chrome.

After that, you need to install the certificate in the Keystore, in the case of

java 8 : jdk->jre->lib->security

java 11 : jdk->lib->security

command to install the certificate :

keytool -import -noprompt -trustcacerts -alias -file -keystore -storepass

The question had been asked more than 2 years ago but hope someone will get help from this.