How to fix Maven error, PKIX path building failed

When you are importing the maven project in eclipse and build the project. it will look the pom.xml to download all the dependency jars but you may get the following errors

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target



Before configuring certificates to cacerts or changing the JAVA Home path, first, check if you have correct proxy settings in the Maven user settings.xml file. Follow the below steps to locate the settings.xml 1. Go to windows > Preferences > Maven > User Settings and click on an open file.


2. In case you are using your Company Proxy for the internet connection, Make sure to provide the proxy details in the settings.xml as mentioned below.

3. If you are using a VPN in your company to connect the internet and client URLs. you need to configure the settings.xml as mentioned below.





4. you can use new SSL connectivity for Maven Central was made available in august, 2014 as follows.

<settings>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>securecentral</activeProfile>
  </activeProfiles>
  <profiles>
    <profile>
      <id>securecentral</id>
      <!--Override the repository (and pluginRepository) "central" from the
         Maven Super POM -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://repo1.maven.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://repo1.maven.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

</setting>

5. There is another approach to use simple http maven repository like this

<pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <name>Maven Plugin Repository</name>
      <url>http://repo1.maven.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
    </pluginRepository>

  </pluginRepositories>

Please let me know if you are able to fix the issue.Thanks and Happy Learning!

Comments