Summary

      Confluence 6.1 installed with the installer on Linux cannot start with embedded JRE because neither JAVA_HOME nor JRE_HOME are set by setenv script

      Environment

      Confluence 6.1.0
      Ubuntu 14.04

      Steps to Reproduce

      1. Install Confluence with the installer (x64) on Linux
      2. Choose Not start
      3. Go to $CONFLUENCE_INSTALL/bin
      4. ./start_confluence.sh

        Expected Results

      Confluence started

      root@ip-172-31-33-170:/opt/atlassian/confluence/bin# ./start-confluence.sh 
      
      To run Confluence in the foreground, start the server with start-confluence.sh -fg
      executing using dedicated user: confluence
      If you encounter issues starting up Confluence, please see the Installation guide at http://confluence.atlassian.com/display/DOC/Confluence+Installation+Guide
      
      Server startup logs are located in /opt/atlassian/confluence/logs/catalina.out
      ---------------------------------------------------------------------------
      Using Java: /opt/atlassian/confluence/jre//bin/java
      2017-03-21 12:42:10,107 INFO [main] [atlassian.confluence.bootstrap.SynchronyProxyWatchdog] A Context element for ${confluence.context.path}/synchrony-proxy is found in /opt/atlassian/confluence/conf/server.xml. No further action is required
      ---------------------------------------------------------------------------
      Using CATALINA_BASE:   /opt/atlassian/confluence
      Using CATALINA_HOME:   /opt/atlassian/confluence
      Using CATALINA_TMPDIR: /opt/atlassian/confluence/temp
      Using JRE_HOME:        /opt/atlassian/confluence/jre/
      Using CLASSPATH:       /opt/atlassian/confluence/bin/bootstrap.jar:/opt/atlassian/confluence/bin/tomcat-juli.jar
      Using CATALINA_PID:    /opt/atlassian/confluence/work/catalina.pid
      Tomcat started.
      

      Actual Results

      Confluence cannot start, no logs are created in catalina.out or Confluence home.
      The console showing the issue

      root@ip-172-31-33-170:/opt/atlassian/confluence/bin# ./start-confluence.sh 
      
      To run Confluence in the foreground, start the server with start-confluence.sh -fg
      executing using dedicated user: confluence
      If you encounter issues starting up Confluence, please see the Installation guide at http://confluence.atlassian.com/display/DOC/Confluence+Installation+Guide
      
      Server startup logs are located in /opt/atlassian/confluence/logs/catalina.out
      Checking operation system...
      Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
      
      

      Root Cause

      The issue is happening because of incorrect logic in the script setjre.sh :

        if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then
          echo "Neither the JAVA_HOME nor the JRE_HOME environment variable is defined"
          echo "At least one of these environment variable is needed to run this program"
          exit 1
        fi
      fi
      if [ -z "$JAVA_HOME" -a "$1" = "debug" ]; then
        echo "JAVA_HOME should point to a JDK in order to run in debug mode."
        exit 1
      fi
      if [ -z "$JRE_HOME" ]; then
        JRE_HOME="$JAVA_HOME"
      fi
      
      echo "Setting JRE_HOME...."
      JRE_HOME="/opt/atlassian/confluence/jre/"; export JRE_HOME
      

      When the execution will got into the condition {{ if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]}} it terminates with exit 1; so JRE_HOME="/opt/atlassian/confluence/jre/"; export JRE_HOME will never be executed.

      There's a bug in the shell script. If there's a /usr/bin/java file, then JRE_HOME will be temporarily set to /usr and then it will be corrected at the end of the script. So this issue happens on a Linux machine that doesn't have the default JVM installed.

      Workaround(s)

      • Set JAVA_HOME="/opt/atlassian/confluence/jre/" explicitly before starting Confluence (keep in mind that /opt/atlassian/confluence/jre is the path to Confluence installation direcotry and should be adapted if you are using your own path)
      • Use Confluence with external Oracle JDK (recommended)
      • Remove the exit 1 lines
      • Move JRE_HOME="/opt/atlassian/confluence/jre/"; export JRE_HOME to the top of setjre.sh

          Form Name

            [CONFSERVER-51937] JRE_HOME is not set when using Linux(x64) installer

            A fix for this issue is now available for Confluence Server customers.
            Upgrade now or check out the Release Notes to see what other issues are resolved.

            Feng Xu (Inactive) added a comment - A fix for this issue is now available for Confluence Server customers. Upgrade now or check out the Release Notes to see what other issues are resolved.

            also setting export JAVA_HOME="/opt/atlassian/confluence/jre"

            at the top of /etc/init.d/confluence works, but it is prone to being overwritten when upgraded

            Joris Benschop added a comment - also setting export JAVA_HOME="/opt/atlassian/confluence/jre" at the top of /etc/init.d/confluence works, but it is prone to being overwritten when upgraded

            Hi Christian,

            This actually worked, thanks!

            Igor 

            Igor Totic added a comment - Hi Christian, This actually worked, thanks! Igor 

            As a workaroud if your installation directory is  /opt/atlassian/confluence you can place 
            JRE_HOME="/opt/atlassian/confluence/jre/"; export JRE_HOME
            at the top of the script.

             

            Christian

            Christian König added a comment - As a workaroud if your installation directory is  /opt/atlassian/confluence you can place  JRE_HOME="/opt/atlassian/confluence/jre/"; export JRE_HOME at the top of the script.   Christian

            Igor Totic added a comment -

            Hi Anton,

            No, i'm using the default install and the path is fine 

             

            Igor

            Igor Totic added a comment - Hi Anton, No, i'm using the default install and the path is fine    Igor

            Hi Igor
            /opt/atlassian/confluence/jre/ should be changed in case of you're using different path for CONFLUENCE_INSTALL directory.

            Anton Shaleev added a comment - Hi Igor /opt/atlassian/confluence/jre/ should be changed in case of you're using different path for CONFLUENCE_INSTALL directory.

            Igor Totic added a comment -

            Hi,

            We are still having this issue even after setting the JAVA_HOME directory: 

             

            [root@dedcs1-wikit01 ~]# echo $JAVA_HOME
            /opt/atlassian/confluence/jre/
            

            Is there anything we need to change in the script? 

             

             

            Regards,

            Igor 

            Igor Totic added a comment - Hi, We are still having this issue even after setting the JAVA_HOME directory:    [root@dedcs1-wikit01 ~]# echo $JAVA_HOME /opt/atlassian/confluence/jre/ Is there anything we need to change in the script?      Regards, Igor 

              ttranminh Tam Tran
              ashaleev Anton Shaleev
              Affected customers:
              8 This affects my team
              Watchers:
              22 Start watching this issue

                Created:
                Updated:
                Resolved: