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

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

            Katherine Yabut made changes -
            Workflow Original: JAC Bug Workflow v3 [ 2878159 ] New: CONFSERVER Bug Workflow v4 [ 3004137 ]
            Owen made changes -
            Workflow Original: JAC Bug Workflow v2 [ 2778523 ] New: JAC Bug Workflow v3 [ 2878159 ]
            Status Original: Resolved [ 5 ] New: Closed [ 6 ]
            Owen made changes -
            Workflow Original: JAC Bug Workflow [ 2717730 ] New: JAC Bug Workflow v2 [ 2778523 ]
            Owen made changes -
            Symptom Severity Original: Major [ 14431 ] New: Severity 2 - Major [ 15831 ]
            Owen made changes -
            Workflow Original: Confluence Workflow - Public Facing - Restricted v5 - TEMP [ 2382844 ] New: JAC Bug Workflow [ 2717730 ]
            Katherine Yabut made changes -
            Workflow Original: Confluence Workflow - Public Facing - Restricted v5 [ 2275910 ] New: Confluence Workflow - Public Facing - Restricted v5 - TEMP [ 2382844 ]
            Michael Andreacchio made changes -
            UIS Original: 23
            Katherine Yabut made changes -
            Workflow Original: Confluence Workflow - Public Facing - Restricted v5.1 - TEMP [ 2218471 ] New: Confluence Workflow - Public Facing - Restricted v5 [ 2275910 ]
            Katherine Yabut made changes -
            Workflow Original: Confluence Workflow - Public Facing - Restricted v5 - TEMP [ 2172547 ] New: Confluence Workflow - Public Facing - Restricted v5.1 - TEMP [ 2218471 ]
            Katherine Yabut made changes -
            Workflow Original: Confluence Workflow - Public Facing - Restricted v5 [ 1934812 ] New: Confluence Workflow - Public Facing - Restricted v5 - TEMP [ 2172547 ]

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

                Created:
                Updated:
                Resolved: