Issue Summary

      Service.bat wrongly sets JRE_HOME variable value in JIRA 8.11 service.bat if the JRE_HOME variable is not set explicitly.

      Steps to Reproduce

      Without setting any Environment variable (like JAVA_HOME or JRE_HOME)
      1) Install 8.7 first. Install JIRA as windows service.
      2) Now download JIRA 8.11. Upgrade the existing JIRA 8.7 to 8.11. Remove the old JIRA 8.7 windows service using service.bat
      3) Try installing the jira 8.11 using service.bat. We see the below error

      Installing the service 'jira' ...
      Using CATALINA_HOME:    "C:\Program Files\Atlassian\Jira"
      Using CATALINA_BASE:    "C:\Program Files\Atlassian\Jira"
      Ignoring JAVA_HOME:        ""C:\Program Files\OpenJDK\jdk8u212-b04""
      Using JRE_HOME:         "C:\Users\Administrator\jre"
      Warning: Neither 'server' nor 'client' jvm.dll was found at JRE_HOME.
      Using JVM:              "auto"
      ****************************************************************************
      *******      Wrong JVM version Jira requires 1.8 or 11 to run.      *******
      ****************************************************************************
      ***
      *** Output of java -version command is:
      The system cannot find the path specified.
      *** (End of output) ***
      ***
      *** If you want JIRA to start using this JVM
      *** set environment variable 'ignore_jvm_version' to 'true'
      ***
      ****************************************************************************
      

      Expected Results

      THE JRE HOME is picked from the right location and service is installed.

      Actual Results

      The below exception is thrown in the command prompt while installing JIRA as a service:

      C:\Users\Administrator>"C:\Program Files\Atlassian\Jira\bin\service.bat" install jira
      Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
      Service will use the bundled JRE.
      Failing that, service will try to guess them from the registry.
      
      Granting full access for Network Service to the Jira home directory 'C:\Program Files\Atlassian\Application Data\Jira'
      processed file: C:\Program Files\Atlassian\Application Data\Jira
      Successfully processed 1 files; Failed processing 0 files
      
      Granting read and execute access for Network Service to the Jira installation directory 'C:\Program Files\Atlassian\Jira'
      processed file: C:\Program Files\Atlassian\Jira
      Successfully processed 1 files; Failed processing 0 files
      
      Granting full access for Network Service to the work, temp and logs subdirectories of Jira installation directory 'C:\Program Files\Atlassian\Jira'
      processed file: C:\Program Files\Atlassian\Jira/work
      Successfully processed 1 files; Failed processing 0 files
      processed file: C:\Program Files\Atlassian\Jira/temp
      Successfully processed 1 files; Failed processing 0 files
      processed file: C:\Program Files\Atlassian\Jira/logs
      Successfully processed 1 files; Failed processing 0 files
      
      Granting read and execute access for Network Service for parent directories of the Jira home directory 'C:\Program Files\Atlassian\Application Data\Jira'.
      They're required to make Java native IO operations work, which are required e.g. when starting up the plugin system.
      Starting to walk up from: "C:\Program Files\Atlassian\Application Data\Jira\"
      
      Checking permissions of C:\Program Files\Atlassian\Application Data\Jira\ [C:\Program Files\Atlassian\Application Data\Jira\]
      
      Checking permissions of C:\Program Files\Atlassian\Application Data\ [C:\Program Files\Atlassian\Application Data\Jira\..\]
      
      Checking permissions of C:\Program Files\Atlassian\ [C:\Program Files\Atlassian\Application Data\Jira\..\..\]
      
      Checking permissions of C:\Program Files\ [C:\Program Files\Atlassian\Application Data\Jira\..\..\..\]
      Granting read and execute access for Network Service to C:\Program Files\
      C:\Program Files\.: Access is denied.
      Successfully processed 0 files; Failed processing 1 files
      end
      
      Granting read and execute access for Network Service for parent directories of the Jira installation directory 'C:\Program Files\Atlassian\Jira'.
      They're required to make Java native IO operations work, which are required e.g. when starting up the plugin system.
      Starting to walk up from: "C:\Program Files\Atlassian\Jira\"
      
      Checking permissions of C:\Program Files\Atlassian\Jira\ [C:\Program Files\Atlassian\Jira\]
      
      Checking permissions of C:\Program Files\Atlassian\ [C:\Program Files\Atlassian\Jira\..\]
      
      Checking permissions of C:\Program Files\ [C:\Program Files\Atlassian\Jira\..\..\]
      Granting read and execute access for Network Service to C:\Program Files\
      C:\Program Files\.: Access is denied.
      Successfully processed 0 files; Failed processing 1 files
      end
      Installing the service 'jira' ...
      Using CATALINA_HOME:    "C:\Program Files\Atlassian\Jira"
      Using CATALINA_BASE:    "C:\Program Files\Atlassian\Jira"
      Ignoring JAVA_HOME:        ""C:\Program Files\OpenJDK\jdk8u212-b04""
      Using JRE_HOME:         "C:\Users\Administrator\jre"
      Warning: Neither 'server' nor 'client' jvm.dll was found at JRE_HOME.
      Using JVM:              "auto"
      ****************************************************************************
      *******      Wrong JVM version Jira requires 1.8 or 11 to run.      *******
      ****************************************************************************
      ***
      *** Output of java -version command is:
      The system cannot find the path specified.
      *** (End of output) ***
      ***
      *** If you want JIRA to start using this JVM
      *** set environment variable 'ignore_jvm_version' to 'true'
      ***
      ****************************************************************************
      

      Workaround

      ADD JRE_HOME environment variable in the windows server pointing to the root folder of where the JRE is located. Restart the windows server to take this into effect and then try installing jira as windows service using service.bat

          Form Name

            [JRASERVER-71475] Service.bat wrongly sets JRE_HOME variable

            Wing added a comment - - edited

            This is still an issue with Jira 8.13.2.

            I had spacing issues with setting JRE_HOME manually (the batch file didn't like the spaces in "Program Files"), so per Aditya's comment above I updated service.bat with the following:

             

             set "BIN_DIR=%~dp0"
             set "JRE_HOME=%BIN_DIR%\..\jre"
            

             

            Wing added a comment - - edited This is still an issue with Jira 8.13.2. I had spacing issues with setting JRE_HOME manually (the batch file didn't like the spaces in "Program Files"), so per Aditya's comment above I updated service.bat with the following:    set "BIN_DIR=%~dp0"  set "JRE_HOME=%BIN_DIR%\..\jre"  

            I got also this error from Jira 8.13.1

            Armand Gino T. Agapito added a comment - I got also this error from Jira 8.13.1

            Aditya M added a comment -

            After further digging into the service.bat, we could see a difference between service.bat from jira 8.7 and jira 8.11

            In 8.7 this is line that sets JRE_HOME if we do not have JRE_HOME environment variable set.

            set "JRE_HOME=%BIN_DIR%\..\jre"
            

            However, in 8.11, this is the piece of line that gets executed if we do not have JRE_HOME environment variable set.

            set "JRE_HOME=%CURRENT_DIR%\jre"
            

            And this %CURRENT_DIR%\jre is not the right path for the JRE_HOME. And that is why as soon as we set JRE_HOME environment variable, this path is ignored and the value from the environment variable is picked.

            Aditya M added a comment - After further digging into the service.bat, we could see a difference between service.bat from jira 8.7 and jira 8.11 In 8.7 this is line that sets JRE_HOME if we do not have JRE_HOME environment variable set. set "JRE_HOME=%BIN_DIR%\..\jre" However, in 8.11, this is the piece of line that gets executed if we do not have JRE_HOME environment variable set. set "JRE_HOME=%CURRENT_DIR%\jre" And this %CURRENT_DIR%\jre is not the right path for the JRE_HOME. And that is why as soon as we set JRE_HOME environment variable, this path is ignored and the value from the environment variable is picked.

              mrydzewski Mikolaj Rydzewski (Inactive)
              amukkamala Aditya M
              Affected customers:
              3 This affects my team
              Watchers:
              10 Start watching this issue

                Created:
                Updated:
                Resolved: