Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-17362

Maven build cannot find JDK when project uses default

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • maven-plugin
    • None
    • Windows 2003 server and Tomcat 7.0.23

      I recently installed JDK 6.0.43, and after removing the old versions of Java my projects with a default JDK no longer build, with an error from maven that it can't find tools.jar.

      Jenkins is running in Tomcat with the war renamed to Hudson for historical reasons, and Tomcat is running with JDK 6.0.43. JDK7 is installed on the server and configured in Jenkins, but JAVA_HOME is also set to JDK 6.0.43, so I don't know where the jre7 is getting set.
      This is a problem because I have about 170 projects. Setting the specific JDK for each would be BAD, changing it for jdk7 later would be worse.

      [ERROR] BUILD ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] Fatal error compiling

      Embedded error: tools.jar not found: D:\Applicazioni\Java\jre7\..\lib\tools.jar
      [INFO] ------------------------------------------------------------------------
      [INFO] Trace
      org.apache.maven.lifecycle.LifecycleExecutionException: Fatal error compiling
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
      at org.apache.maven.lifecycle.LifecycleExecutorInterceptor.execute(LifecycleExecutorInterceptor.java:65)

          [JENKINS-17362] Maven build cannot find JDK when project uses default

          I tried disinstalling all JDKs except the one I wanted, and deleting the JDK configurations from Jenkins, reinstalling Jenkins and restarting the server, but there was no difference in the error. I deleted the folder that Maven was searching and Maven/Jenkins then used the remaining public JRE,
          Embedded error: tools.jar not found: C:\Program Files\Java\jre6\..\lib\tools.jar

          Philip Kerrigan added a comment - I tried disinstalling all JDKs except the one I wanted, and deleting the JDK configurations from Jenkins, reinstalling Jenkins and restarting the server, but there was no difference in the error. I deleted the folder that Maven was searching and Maven/Jenkins then used the remaining public JRE, Embedded error: tools.jar not found: C:\Program Files\Java\jre6\..\lib\tools.jar

          Jirong Hu added a comment -

          I am having the same issue. Run "mvn compile" from DOS command line is all right, but getting this error from Jenkins. Very simple Maven "my-app" sample project. Even I copied the tool.jar to the path below, still same error.

          I am running the build on a Slave on XP, in the System Information of Slave, the JAVA_HOME is showing different.

          [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project my-app: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre7\..\lib\tools.jar -> [Help 1]
          [ERROR]

          Jirong Hu added a comment - I am having the same issue. Run "mvn compile" from DOS command line is all right, but getting this error from Jenkins. Very simple Maven "my-app" sample project. Even I copied the tool.jar to the path below, still same error. I am running the build on a Slave on XP, in the System Information of Slave, the JAVA_HOME is showing different. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project my-app: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre7\..\lib\tools.jar -> [Help 1] [ERROR]

          Lukasz D added a comment -

          It looks like the issue exists on Jenkins ver. 1.550 on Windows 2008 R2 slave (JDK 7u51, JAVA_HOME is set to C:\Program Files\Java\jdk1.7.0_51). On Jenkins master node (Debian 7.2) in JDK section in configuration settings there's no JDK defined. I duplicated JAVA_HOME variable in slave node representation settings but without any success either (I restarted Jenkins and slave connections several times (both jnlp and java -jar don't work anyway)) -maven build still fails.
          The work-around for users who don't rely on JDK version is to copy lib folder to path provided in error msg (in my case it was C:\Program Files\Java\lib).

          Lukasz D added a comment - It looks like the issue exists on Jenkins ver. 1.550 on Windows 2008 R2 slave (JDK 7u51, JAVA_HOME is set to C:\Program Files\Java\jdk1.7.0_51). On Jenkins master node (Debian 7.2) in JDK section in configuration settings there's no JDK defined. I duplicated JAVA_HOME variable in slave node representation settings but without any success either (I restarted Jenkins and slave connections several times (both jnlp and java -jar don't work anyway)) -maven build still fails. The work-around for users who don't rely on JDK version is to copy lib folder to path provided in error msg (in my case it was C:\Program Files\Java\lib).

            Unassigned Unassigned
            pkerrigan Philip Kerrigan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: