Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-46152

JIRA Software should detect the Java version correctly

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Low Low (View bug fix roadmap)
    • None
    • 7.0.0
    • Installation

      When trying to launch JIRA Software 7, the version detection is unable to detect our Java version correctly and stops booting. The error shown is:

      *************************************************************************************************************************************
      **********     Wrong JVM version! You are running with .. but JIRA requires at least 1.8 to run.      **********
      *************************************************************************************************************************************
      

      The version is named as "..", which obviously seems to be a detection issue.
      We also tried to set the JAVA_HOME environment variable, which didn't make any change.

            [JRASERVER-46152] JIRA Software should detect the Java version correctly

            Igor Polovykh added a comment - - edited

            no comments. Full degradation of developers.

            Igor Polovykh added a comment - - edited no comments. Full degradation of developers.

            Here's a fixed check-java.sh file

            bin/check-java.sh
            #!/bin/sh#
            # check for correct java version by parsing out put of java -version
            # we expect first line to be in format 'java version "1.8.0_161"' or 'java version "10.0.1" 2018-04-17'
            # or 'openjdk version "11-ea" 2018-09-25' and assert that version number will be 8 or 11 (if enabled)
            # or sth like 'Picked up JDK_JAVA_OPTIONS:' (which we need to skip)
            #java_raw_version=`echo "$($_RUNJAVA -version 2>&1)" | grep -v "JDK_JAVA_OPTIONS" | grep "version" | awk '{ print substr($3, 2, length($3)-2); }'`
            java_version=0if [[ $java_raw_version = *-ea* ]]
            then
                # early access format e.g 11-ea
                IFS='-' read -a values <<< "$java_raw_version"
                java_version=${values[0]}
            else
                if [[ $java_raw_version = 1.* ]]
                then
                    # old format e.g. 1.8.0_161
                    IFS='.' read -a values <<< "$java_raw_version"
                    java_version=${values[1]}
                else
                    # new format e.g. 10.0.1
                    IFS='.' read -a values <<< "$java_raw_version"
                    java_version=${values[0]}
                fi
            fiif [ $java_version -ne 8 ] && [ $java_version -ne 11 ]
            then
                echo "****************************************************************************"
                echo "*******      Wrong JVM version! Jira requires 1.8 or 11 to run.      *******"
                echo "****************************************************************************"
                echo "***"
                echo "*** Output of java -version command is:"
                $_RUNJAVA -version 2>&1
                echo "*** (End of output) ***"
                echo "***"
                if [ "$ignore_jvm_version" = "true" ]
                then
                    echo "*** Environment variable 'ignore_jvm_version' is set to 'true'"
                    echo "*** Jira is going to bypass restriction and run using existing JVM version"
                    echo "***"
                    echo "****************************************************************************"
                else
                    echo "*** If you want Jira to start using this JVM"
                    echo "*** set environment variable 'ignore_jvm_version' to 'true'"
                    echo "***"
                    echo "****************************************************************************"
                    exit 1
                fi
            fi   

            Andrew Nepyivoda (Inactive) added a comment - Here's a fixed check-java.sh file bin/check-java.sh #!/bin/sh# # check for correct java version by parsing out put of java -version # we expect first line to be in format 'java version "1.8.0_161" ' or 'java version "10.0.1" 2018-04-17' # or 'openjdk version "11-ea" 2018-09-25' and assert that version number will be 8 or 11 ( if enabled) # or sth like 'Picked up JDK_JAVA_OPTIONS:' (which we need to skip) #java_raw_version=`echo "$($_RUNJAVA -version 2>&1)" | grep -v "JDK_JAVA_OPTIONS" | grep "version" | awk '{ print substr($3, 2, length($3)-2); }' ` java_version=0if [[ $java_raw_version = *-ea* ]] then     # early access format e.g 11-ea     IFS= '-' read -a values <<< "$java_raw_version"     java_version=${values[0]} else     if [[ $java_raw_version = 1.* ]]     then         # old format e.g. 1.8.0_161         IFS= '.' read -a values <<< "$java_raw_version"         java_version=${values[1]}     else         # new format e.g. 10.0.1         IFS= '.' read -a values <<< "$java_raw_version"         java_version=${values[0]}     fi fiif [ $java_version -ne 8 ] && [ $java_version -ne 11 ] then     echo "****************************************************************************"     echo "*******      Wrong JVM version! Jira requires 1.8 or 11 to run.      *******"     echo "****************************************************************************"     echo "***"     echo "*** Output of java -version command is:"     $_RUNJAVA -version 2>&1     echo "*** (End of output) ***"     echo "***"     if [ "$ignore_jvm_version" = " true " ]     then         echo "*** Environment variable 'ignore_jvm_version' is set to ' true ' "         echo "*** Jira is going to bypass restriction and run using existing JVM version"         echo "***"         echo "****************************************************************************"     else         echo "*** If you want Jira to start using this JVM"         echo "*** set environment variable 'ignore_jvm_version' to ' true ' "         echo "***"         echo "****************************************************************************"         exit 1     fi fi  

            nhanpt14 added a comment -

            You can test check-java.sh script with -x options like:

            sh -x /data/atlassian-jira/bin/check-java.sh
            + _EXPECTED_JAVA_VERSION=8
            ++ which java
            + _RUNJAVA=/bin/java
            + /bin/java -version
            + grep 'java version'
            + IFS=.
            + read ignore1 version ignore2
            + '[' '!' 8 -ge 8 ']'
            + '[' 0 -ne 0 ']'

            ==> It's mean you need to set _RUNJAVA with a right path

            _RUNJAVA=`which java`

             

            nhanpt14 added a comment - You can test check-java.sh script with -x options like: sh -x /data/atlassian-jira/bin/check-java.sh + _EXPECTED_JAVA_VERSION=8 ++ which java + _RUNJAVA=/bin/java + /bin/java -version + grep 'java version' + IFS=. + read ignore1 version ignore2 + ' [' '!' 8 -ge 8 '] ' + ' [' 0 -ne 0 '] ' ==> It's mean you need to set _RUNJAVA with a right path _RUNJAVA=`which java`  

            For those who don't know shell scripting well enough, here's a fixed check-java.sh file that takes into account both major and minor versions...

            bin/check-java.sh
            #!/bin/sh
            
            _EXPECTED_JAVA_MAJOR_VERSION="1"
            _EXPECTED_JAVA_MINOR_VERSION="8"
            
            #
            # check for correct java version by parsing out put of java -version
            # we expect first line to be in format '(java|openjdk) version "1.8.0_40"' and assert that minor version number will be 8 or higher
            #
            
            "$_RUNJAVA" -version 2>&1 | perl -nE 'if ( /(?:java|openjdk)\s+version\s+"?([\d\.]+)"?/ ) { print "$1\n" }' | (
                    OK=0
                    IFS=. read major minor build
                    if [ ${major:-0} -gt "$_EXPECTED_JAVA_MAJOR_VERSION" ]; then
                      OK=1
                    elif [ ${major:-0} -eq "$_EXPECTED_JAVA_MAJOR_VERSION" ] && [ ${minor:-0} -gt "$_EXPECTED_JAVA_MINOR_VERSION" ]; then
                      OK=1
                    fi
                    if [ $OK != 1 ]
                    then
                      echo "******************************************************************************"
                      echo "***  Wrong JVM version! You are running with $major.$minor.$build"
                      echo "***  but JIRA requires at least 1.8 to run."
                      echo "******************************************************************************"
                      exit 1
                    fi
                )
            if [ $? -ne 0 ] ; then
               exit 1
            fi
            
             

            Packy Anderson added a comment - For those who don't know shell scripting well enough, here's a fixed check-java.sh file that takes into account both major and minor versions... bin/check-java.sh #!/bin/sh _EXPECTED_JAVA_MAJOR_VERSION= "1" _EXPECTED_JAVA_MINOR_VERSION= "8" # # check for correct java version by parsing out put of java -version # we expect first line to be in format '(java|openjdk) version "1.8.0_40" ' and assert that minor version number will be 8 or higher # "$_RUNJAVA" -version 2>&1 | perl -nE ' if ( /(?:java|openjdk)\s+version\s+ "?([\d\.]+)" ?/ ) { print "$1\n" }' | ( OK=0 IFS=. read major minor build if [ ${major:-0} -gt "$_EXPECTED_JAVA_MAJOR_VERSION" ]; then OK=1 elif [ ${major:-0} -eq "$_EXPECTED_JAVA_MAJOR_VERSION" ] && [ ${minor:-0} -gt "$_EXPECTED_JAVA_MINOR_VERSION" ]; then OK=1 fi if [ $OK != 1 ] then echo "******************************************************************************" echo "*** Wrong JVM version! You are running with $major.$minor.$build" echo "*** but JIRA requires at least 1.8 to run." echo "******************************************************************************" exit 1 fi ) if [ $? -ne 0 ] ; then exit 1 fi

            That doesn't fix the problem!
            Holy crap, don't hack scripts if you don't know what you are doing.

            If you want to run this script stand-alone you need to set the variable _RUNJAVA first.
            export _RUNJAVA=java

            ./check-java.sh; echo $?

            It should print 0 indicating the script returned with no error.
            This won't tell you much though since you're probably not running in the same context that Jira is launched in. (su -l jira first maybe?)

            This script looks like it's run from some other part of the Jira start-up process and if it fails it will probably log it.

            ShannonBarber added a comment - That doesn't fix the problem! Holy crap, don't hack scripts if you don't know what you are doing. If you want to run this script stand-alone you need to set the variable _RUNJAVA first. export _RUNJAVA=java ./check-java.sh; echo $? It should print 0 indicating the script returned with no error. This won't tell you much though since you're probably not running in the same context that Jira is launched in. (su -l jira first maybe?) This script looks like it's run from some other part of the Jira start-up process and if it fails it will probably log it.

            Caterine Oliveira added a comment - - edited

            On check-java.sh file I changed the expected version to 0 and worked!

            #!/bin/sh

            _EXPECTED_JAVA_VERSION="0"

            #

            1. check for correct java version by parsing out put of java -version
            2. we expect first line to be in format 'java version "1.8.0_40"' and assert that minor version number will be 8 or higher
              #

            "$_RUNJAVA" -version 2>&1 | grep "java version" | (
            IFS=. read ignore1 version ignore2
            if [ ! ${version:-0} -ge "$_EXPECTED_JAVA_VERSION" ]
            then
            echo "*************************************************************************************************************************************"
            echo "********** Wrong JVM version! You are running with "$ignore1"."$version"."$ignore2" but JIRA requires at least 1.8 to run. **********"
            echo "*************************************************************************************************************************************"
            exit 1
            fi
            )
            if [ $? -ne 0 ] ; then
            exit 1
            fi

            Caterine Oliveira added a comment - - edited On check-java.sh file I changed the expected version to 0 and worked! #!/bin/sh _EXPECTED_JAVA_VERSION="0" # check for correct java version by parsing out put of java -version we expect first line to be in format 'java version "1.8.0_40"' and assert that minor version number will be 8 or higher # "$_RUNJAVA" -version 2>&1 | grep "java version" | ( IFS=. read ignore1 version ignore2 if [ ! ${version:-0} -ge "$_EXPECTED_JAVA_VERSION" ] then echo "*************************************************************************************************************************************" echo "********** Wrong JVM version! You are running with "$ignore1"."$version"."$ignore2" but JIRA requires at least 1.8 to run. **********" echo "*************************************************************************************************************************************" exit 1 fi ) if [ $? -ne 0 ] ; then exit 1 fi

            parrieta83 added a comment -

            Hey guys,
            I'm having the same issue here:
            "Wrong JVM version! You are running with java version "9.0.1" but JIRA requires at least 1.8 to run."

            Any suggestions??

            Jira 7.7.0
            JDK 9.0.1
            HighSierra 10.13.2 

            Thanks in advance!
            Pablo

            parrieta83 added a comment - Hey guys, I'm having the same issue here: "Wrong JVM version! You are running with java version "9.0.1" but JIRA requires at least 1.8 to run." Any suggestions?? Jira 7.7.0 JDK 9.0.1 HighSierra 10.13.2  Thanks in advance! Pablo

            found it!! in check-java.sh ... got it working now

            Peter Boskens added a comment - found it!! in check-java.sh ... got it working now

            hey Alfredo, do you have the complete solution? I have the same problem and really want to get this Jira software running!
            best regards,
            and happy holidays,
            Peter

            Peter Boskens added a comment - hey Alfredo, do you have the complete solution? I have the same problem and really want to get this Jira software running! best regards, and happy holidays, Peter

            Same problem here

            • ubuntu x86
            • Jira 7.6.0
            • openjdk version "1.8.0_151"
            • OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
            • OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

            Rémi Tuyaerst added a comment - Same problem here ubuntu x86 Jira 7.6.0 openjdk version "1.8.0_151" OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12) OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

              Unassigned Unassigned
              e4cf938a007e Andreas Hofmann
              Affected customers:
              1 This affects my team
              Watchers:
              28 Start watching this issue

                Created:
                Updated:
                Resolved: