Search code examples
javaeclipsemavenpom.xmltoolchain

Failed to Build Application Getting Error::No toolchain found for type jdk


I have tried different solution for this but didn't work for me,

please see the error log and toolchain.xml file.

These are error logs:

[INFO] --- maven-toolchains-plugin:1.1:toolchain (default) @ ad-api ---
[INFO] Required toolchain: jdk [ vendor='sun' version='1.8' ]
[ERROR] No toolchain found for type jdk
[ERROR] Cannot find matching toolchain definitions for the following toolchain types:
jdk [ vendor='sun' version='1.8' ]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.619 s
[INFO] Finished at: 2018-10-05T08:56:24+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain (default) on project ad-api: Cannot find matching toolchain definitions for the following toolchain types:
[ERROR] jdk [ vendor='sun' version='1.8' ]
[ERROR] Please make sure you define the required toolchains in your ~/.m2/toolchains.xml file.
[ERROR] -> [Help 1]
[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/MojoFailureException

getting above error while i have updated version 1.8 to jdk1.8._172

below is my pom.xml

 <plugins>

   <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
   </plugin>

   <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-toolchains-plugin</artifactId>
      <executions>
         <execution>
            <goals>
               <goal>toolchain</goal>
            </goals>
         </execution>
      </executions>
      <configuration>
         <toolchains>
            <jdk>
               <version>jdk1.8.0_172</version>
               <vendor>sun</vendor>
            </jdk>
         </toolchains>
      </configuration>
   </plugin>

   <plugin>
      <artifactId>maven-resources-plugin</artifactId>
      <configuration>
         <encoding>${project.build.sourceEncoding}</encoding>
      </configuration>
   </plugin>

</plugins>

and I have defined jdk path in toolchain.xml

<toolchains>
    <toolchain>
    <type>jdk</type>
    <provides>
      <version>1.8</version>
      <vendor>sun</vendor>
    </provides>
    <configuration>
      <jdkHome>C:\Program Files\Java\jdk1.8.0_172</jdkHome>
    </configuration>
  </toolchain>
</toolchains>

Please help where to resolve the problem. Thanks in advance.


Solution

  • change the version in pom to 1.8 instead of jdk1.8.0_172

                    <configuration>
                        <toolchains>
                            <jdk>
                                <version>1.8</version>
                                <vendor>sun</vendor>
                            </jdk>
                        </toolchains>
                    </configuration>