3

I'm getting the error "/var/jenkins_home/tools/hudson.model.JDK/jdk8/bin/java: not found:" even though the path exists:

   

[edi-debatcher_master-LNI22Y2C5V3VECCBCFPVB3ZUWJJNMLK6LIFEQ6V3OYH52T74NU3A@2] Running shell script
+ echo PATH = /var/jenkins_home/tools/hudson.model.JDK/jdk8/bin:/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.3/bin:/var/jenkins_home/tools/hudson.model.JDK/jdk8/bin:/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
PATH = /var/jenkins_home/tools/hudson.model.JDK/jdk8/bin:/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.3/bin:/var/jenkins_home/tools/hudson.model.JDK/jdk8/bin:/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
+ echo M2_HOME = /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.3
M2_HOME = /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.3
+ mvn -version
/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.3/bin/mvn: exec: line 199: /var/jenkins_home/tools/hudson.model.JDK/jdk8/bin/java: not found

I am using the Jenkins Blue Ocean feature, GitHub Jenkinsfile. I have "jdk8" and "Maven 3.5.3" defined in Global Tool Configuration, "autoinstall" checked.

Here is my Jenkinsfile:


    pipeline {
      agent any
      stages {
        stage('Initialize') {
          steps {
            sh '''
               echo "PATH = ${PATH}"
               echo "M2_HOME = ${M2_HOME}"
               mvn --version 
               '''
          }
        }
        stage('Build') {
          steps {
            sh 'mvn -Dmaven.test.failure.ignore=true install'
          }
          post {
            success {
              junit 'target/surefire-reports/**/*.xml'
            }
          }
        }
      }
      tools {
        maven 'Maven 3.5.3'
        jdk 'jdk8'
      }
      post {
        always {
        deleteDir()
        }
      }
    }

user1198042
  • 61
  • 1
  • 4
  • are you sure that are you checking machine with jenkins slave that executes your job (not other slave or master)? – Bartosz Bilicki Apr 09 '18 at 16:37
  • I found a workaround: instead of the Oracle auto-install JDK I used the default OpenJDK version 8 already installed: /usr/lib/jvm/java-1.8-openjdk ...it could be that there is something wrong with the Oracle JDK autoinstall integration. – user1198042 Apr 09 '18 at 17:54
  • Possible duplicate: https://stackoverflow.com/questions/50120476/jenkins-config-jdk-for-project-and-maven-build-always-get-error/ – Arigion Sep 02 '18 at 13:32

3 Answers3

2

You are running a wrong version of the file (here java) for the system.

Problem: The file is there and can not be executed. The error message is "No such file or directory"

Solution: You are running the wrong file version for your system.

The problem can occur for example if you run your Jenkins installation in a Docker container with Alpine Linux, since Alpine uses musl libc. The Oracle Java binaries only run on glibc.

Arigion
  • 3,267
  • 31
  • 41
1

The problem was that the Oracle JDK autoinstall didn't really do anything on my system (confirmed by checking Jenkins' system properties for Java). I found that openjdk 1.8 happen to already be on that container, so I manually pointed JAVA_HOME to that instead of relying on the Oracle JDK autoinstall.

user1198042
  • 61
  • 1
  • 4
0

Once I changed the project JDK setting to system, my build progressed past this error.

TT.
  • 15,774
  • 6
  • 47
  • 88
rekwet
  • 1
  • 1
  • 2
    Welcome to SO. A really good answer would explain where that setting is (I'm guessing it's in Jenkins?) and why changing that particular setting worked. – arnt Sep 02 '18 at 13:01