1

I use Ubuntu 18.04 , updated Java to latest version 10 and now not able to run simple Maven projects.

Created a simple maven project from Spring Initializer and tried running it.

Following is the error in console

[ERROR] Some problems were encountered while processing the POMs:
[WARNING] 'parent.relativePath' of POM com.mynotes.spring-cloud:spring-cloud-contract-consumer:0.0.1-SNAPSHOT (/home/dhananjay/Github/spring-cloud-contract/spring-cloud-contract-consumer/pom.xml) points at com.mynotes.spring-cloud:spring-cloud-contract instead of org.springframework.boot:spring-boot-starter-parent, please verify your project structure @ line 14, column 10
[FATAL] Non-resolvable parent POM for com.mynotes.spring-cloud:spring-cloud-contract-consumer:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.5.13.RELEASE from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty and 'parent.relativePath' points at wrong local POM @ line 14, column 10
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[WARNING] 'parent.relativePath' of POM com.mynotes.spring-cloud:spring-cloud-contract-consumer:0.0.1-SNAPSHOT (/home/dhananjay/Github/spring-cloud-contract/spring-cloud-contract-consumer/pom.xml) points at com.mynotes.spring-cloud:spring-cloud-contract instead of org.springframework.boot:spring-boot-starter-parent, please verify your project structure @ line 14, column 10
[FATAL] Non-resolvable parent POM for com.mynotes.spring-cloud:spring-cloud-contract-consumer:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.5.13.RELEASE from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty and 'parent.relativePath' points at wrong local POM @ line 14, column 10

    at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:382)
    at org.apache.maven.graph.DefaultGraphBuilder.collectProjects (DefaultGraphBuilder.java:400)
    at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor (DefaultGraphBuilder.java:391)
    at org.apache.maven.graph.DefaultGraphBuilder.build (DefaultGraphBuilder.java:78)
    at org.apache.maven.DefaultMaven.buildGraph (DefaultMaven.java:511)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:221)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[ERROR]   
[ERROR]   The project com.mynotes.spring-cloud:spring-cloud-contract-consumer:0.0.1-SNAPSHOT (/home/dhananjay/Github/spring-cloud-contract/spring-cloud-contract-consumer/pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for com.mynotes.spring-cloud:spring-cloud-contract-consumer:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.5.13.RELEASE from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty and 'parent.relativePath' points at wrong local POM @ line 14, column 10 -> [Help 2]
org.apache.maven.model.resolution.UnresolvableModelException: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.5.13.RELEASE from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
    at org.apache.maven.project.ProjectModelResolver.resolveModel (ProjectModelResolver.java:197)
    at org.apache.maven.project.ProjectModelResolver.resolveModel (ProjectModelResolver.java:243)
    at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally (DefaultModelBuilder.java:1051)
    at org.apache.maven.model.building.DefaultModelBuilder.readParent (DefaultModelBuilder.java:829)
    at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:331)
    at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:429)
    at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:398)
    at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:362)
    at org.apache.maven.graph.DefaultGraphBuilder.collectProjects (DefaultGraphBuilder.java:400)
    at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor (DefaultGraphBuilder.java:391)
    at org.apache.maven.graph.DefaultGraphBuilder.build (Defaul

I have been getting similar sort of errors in many projects

Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

Googled a bit and found this fix. https://gist.github.com/mikaelhg/527204e746984cf9a33f7910bb8b4cb6 This works for simple Maven project but not working for Spring-related.

Any help would be appreciated.

Reverted back to java 8, and everything works, but I want to know why its not working with java 10.

$ sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                   Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-8-oracle/bin/javac    1081      auto mode
  1            /usr/lib/jvm/java-10-oracle/bin/javac   2         manual mode
* 2            /usr/lib/jvm/java-8-oracle/bin/javac    1081      manual mode

Press <enter> to keep the current choice[*], or type selection number: 

$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                     Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-8-oracle/jre/bin/java   1081      auto mode
  1            /usr/lib/jvm/java-10-oracle/bin/java      2         manual mode
* 2            /usr/lib/jvm/java-8-oracle/jre/bin/java   1081      manual mode

Press <enter> to keep the current choice[*], or type selection number: 

$ java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

$ javac -version
javac 1.8.0_171

POM.xml

<?xml version="1.0" encoding="UTF-8"?>
<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.mynotes.spring-cloud</groupId>
    <artifactId>spring-cloud-contract-producer</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>spring-cloud-contract-producer</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Edgware.SR3</spring-cloud.version>
    </properties>

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-contract-verifier</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>
Dhananjay
  • 1,140
  • 1
  • 12
  • 28
  • 2
    You two issues. First fixing the certificate problem (https)...and furthermore Spring Boot 1.X with JDK 10 does not work...If you like to use JDK9+ you have to go to Spring Boot 2.X .... – khmarbaise May 12 '18 at 20:13
  • latest release https://spring.io/blog/2018/05/09/spring-boot-2-0-2 – Naman May 12 '18 at 20:20
  • Changing boot version to 2.0.2 didnt help. Same error. Can you help me with the https issue. – Dhananjay May 12 '18 at 20:22
  • Show your `pom.xml` – Vy Do May 13 '18 at 10:27
  • pom is attached now. I dont think its the pom or spring issue but rather java-10/ubuntu/https issue what @khmarbaise pointed out. – Dhananjay May 13 '18 at 14:23

2 Answers2

2

We had that issue on a PC at work. It turned out to be a screwed java version. We had installed java 8 oracle instead of openjdk-8.

Remove all your java installations and start from the beginning and make sure you install openjdk instead of oracle's

For uninstalling java I will just refer you to this thread - https://askubuntu.com/questions/84483/how-to-completely-uninstall-java

Installing:

sudo apt-get install openjdk-8-jdk
sashok_bg
  • 2,436
  • 1
  • 22
  • 33
  • Switched back to oracle java 8 and everything works. But I want to know why maven based projects (specially spring) not working with java 10. – Dhananjay May 20 '18 at 19:43
  • run your maven mvn --version and see what version of java it uses. My bet is that it uses java 10. Java 10 on the other hand does not work imo is that is has been packaged by oracle and it does not contain the proper list of central authorities in its certificates list. You import manually the CAs but it's a long stoy – sashok_bg May 20 '18 at 22:48
-1

Java 10 is not supported bu Spring yet.

Switch to Java 8:

sudo update-alternatives --config java

And choose Java 8.

Gala
  • 2,592
  • 3
  • 25
  • 33