4

I'm trying to build maven project, but not at all its working fine.

Here is my POM.xml

    <<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.Data.Maven</groupId>
  <artifactId>Hadoop</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
    <dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-clean-plugin</artifactId>
    <version>2.5</version>
   </dependency>
  </dependencies>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.1.0</version>
        </plugin> 
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>2.4</version>
        </plugin>  
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>2.5</version>
        </plugin>                 
      </plugins>
    </pluginManagement>   
</build>
</project>

setting.xml

<repositories>
   <repository>
      <id>cloudera</id>
      <url>https://repository.cloudera.com/artifactory/cloudera-repos</url>
      <releases>
         <enabled>true</enabled>
      </releases>
      <snapshots>
         <enabled>true</enabled>
      </snapshots>
   </repository>
   <repository>
      <id>central</id>
      <url>http://repo.maven.apache.org/maven2/</url>
   </repository>
   <repository>
      <id>forplay-legacy</id>
      <url>http://forplay.googlecode.com/svn/mavenrepo</url>
   </repository>
   <repository>
      <id>org.apache.maven.plugins</id>
      <url>https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-resources-plugin</url>
   </repository>
   <repository>
      <id>org.apache.maven.plugins</id>
      <url>https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin</url>
   </repository>
</repositories>

Error

[ERROR] Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:3.1: Could not transfer artifact org.apache.maven.plugins:maven-compiler-plugin:pom:3.1 from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

Error says its not able to download artifact from http://repo.maven.apache.org/maven2 url, but am not downloading this url. I've mentioned different in setting.xml.

Is there any way to solve this problem or I could change any setting so that it dont go to this url http://repo.maven.apache.org/maven2 to download but the one mentioned in setting.xml ?

Tried almost all options, like deleting maven repository, mvn install, force updates, deleting project, re-starting eclipse etc etc.

Any help would be appreciated . Really Stuck

Thanks

Marko Previsic
  • 1,820
  • 16
  • 30
Nele
  • 77
  • 2
  • 2
  • 9
  • Which Java Version do you use? Apart from that the entries like `mvnrepository...` will not work cause `mvnrepository` is not a consumable maven repository. – khmarbaise Jul 05 '19 at 17:00
  • openjdk version "1.8.0_171" OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-2~14.04-b11) OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode) – Nele Jul 05 '19 at 17:06
  • But when I run javac -version, It shows javac 11.0.2 – Nele Jul 05 '19 at 17:08
  • If you are using https://repo.maven.apache.org/maven2 you have check that cause the error message looks like you using wrong configuration for SSL...`nexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty...` Can you please check via `mvn --version` what that exactly shows? – khmarbaise Jul 05 '19 at 17:11
  • Maven version 3.0.5 – Nele Jul 05 '19 at 17:38
  • Not the version of Maven more the output which is giving about java home etc. – khmarbaise Jul 05 '19 at 17:47
  • Apache Maven 3.0.5 Maven home: /usr/share/maven Java version: 1.8.0_171, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre Default locale: en_IN, platform encoding: UTF-8 OS name: "linux", version: "4.4.0-148-generic", arch: "amd64", family: "unix" – Nele Jul 05 '19 at 17:49
  • Ah...so we can see that the JAVA_HOME variable points to JDK 8 ..Furthermore why have you configured central with http but your error message shows https instead ? – khmarbaise Jul 05 '19 at 17:51
  • "Furthermore why have you configured central with http but your error message shows https instead " Where .... ? – Nele Jul 05 '19 at 17:53
  • From the above settings.xml: `http://repo.maven.apache.org/maven2/` ..and the error: `central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty`... ? – khmarbaise Jul 05 '19 at 17:54
  • Aha, Lemme try with https ...! Is that okay .. ? – Nele Jul 05 '19 at 17:58
  • You have read the error message? – khmarbaise Jul 05 '19 at 17:59
  • Its not able to get artifacts from central url becasue of some "the trustAnchors parameter must be non-empty" error...! Correct ..? – Nele Jul 05 '19 at 18:01
  • @khmarbaise...Any suggestion please ....? – Nele Jul 05 '19 at 18:10

2 Answers2

5

In maven's semantic versioning, 3.1 and 3.1.0 are not the same thing. Maven't can't locate version 3.1 for this plugin simply because it does not exist. You need to refer to the 3.1.0 version you correctly referred to in the dependencies:

<build>
  <pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.1.0</version> <!-- Here, instead of 3.1 you had in the question -->
      </plugin>           
    </plugins>
  </pluginManagement>   
</build>
Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • Update my Pom and still getting error for 3.1. Please check my question...Why its happening ..? Am I doing really something wrong ..? – Nele Jul 05 '19 at 16:46
  • Will it work to download all maven dependencies using command "mvn dependency:get -DrepoUrl=https://mvnrepository.com/artifact/org.apache.maven.plugins" – Nele Jul 05 '19 at 17:03
  • The resources plugin was not the problem. The error mentioned the maven-compiler-plugin version 3.1 which exists in Central in that version https://search.maven.org/search?q=g:org.apache.maven.plugins%20AND%20a:maven-compiler-plugin&core=gav – khmarbaise Jul 05 '19 at 17:18
0

I was facing the same issue. I just added below dependency in my project pom and rebuilt the project.

<dependency>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <version>3.2.4</version>
  <type>maven-plugin</type>
</dependency>