Uploaded image for project: 'Confluence Server and Data Center'
  1. Confluence Server and Data Center
  2. CONFSERVER-51937

JRE_HOME is not set when using Linux(x64) installer

    XMLWordPrintable

    Details

      Description

      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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ttranminh Tam Tran
              Reporter:
              ashaleev Anton Shaleev
              Votes:
              8 Vote for this issue
              Watchers:
              22 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: