Uploaded image for project: 'JBoss Web Server'
  1. JBoss Web Server
  2. JWS-797

[ASF BZ 61441] Wrong JAVA_HOME/JRE_HOME auto-detection on RHEL

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • None
    • None
    • tomcat
    • None
    • Hide

      1) Download and unzip jws-application-server zip for RHEL
      2) Try and start tomcat from the daemon.sh script:

      [root@rhel7 bin]# pwd
      /root/jws-3.1/tomcat8/bin
      [root@rhel7 bin]# ./daemon.sh start
      Cannot find any VM in Java Home /usr
      
      Show
      1) Download and unzip jws-application-server zip for RHEL 2) Try and start tomcat from the daemon.sh script: [root@rhel7 bin]# pwd /root/jws-3.1/tomcat8/bin [root@rhel7 bin]# ./daemon.sh start Cannot find any VM in Java Home /usr

    Description

      +++ This bug was initially created as a clone of Bug #1120255 +++
      Description of problem:
      On RHEL, when java is installed from rpm, the JAVA_HOME or JRE_HOME environment variables are not set. Luckily, the tomcat startup scripts are able to auto-detect them by:

      daemon.sh:96:

      JAVA_BIN="`which java 2>/dev/null || type java 2>&1`"
      test -x "$JAVA_BIN" && JAVA_HOME="`dirname $JAVA_BIN`"
      test ".$JAVA_HOME" != . && JAVA_HOME=`cd "$JAVA_HOME/.." >/dev/null; pwd`
      

      setclasspath.sh:35:

      JAVA_PATH=`which java 2>/dev/null`
      if [ "x$JAVA_PATH" != "x" ]; then
        JAVA_PATH=`dirname $JAVA_PATH 2>/dev/null`
        JRE_HOME=`dirname $JAVA_PATH 2>/dev/null`
      fi
      

      The problem is that when java is installed from rpm, `which java` evaluates to '/usr/bin/java', which is a symlink maintained by alternatives. The code snippets above will evaluate to JAVA_HOME and JRE_HOME being set to '/usr'.

      Having JRE_HOME set to '/usr' doesn't seem to cause problems for tomcat, because I verified that this issues has been present at least since EWS-2.0.1 and there haven't been any issues with tomcat suggesting a bug with JAVA_HOME/JRE_HOME.

      The problem manifests itself when running the daemon.sh script:

      # ./daemon.sh start'
      Cannot find any VM in Java Home /usr
      
      # grep 'Cannot find any VM in Java Home' ./*
      Binary file ./jsvc matches
      

      jsvc is only used in daemon.sh, therefore this problem was not seen when starting tomcat using startup.sh or catalina.sh.

      I think a good fallback for JAVA_HOME and JRE_HOME is '/usr/lib/jvm/java' and '/usr/lib/jvm/jre' respectively.

      Version-Release number of selected component (if applicable):
      JWS 3.1.0 GA

      How reproducible:
      100%

      Steps to Reproduce:
      1. cd tomcat7/bin
      2. ./daemon.sh start

      Actual results:
      Cannot find any VM in Java Home /usr

      Attachments

        Issue Links

          Activity

            People

              rhn-support-csutherl Coty Sutherland
              rhn-support-csutherl Coty Sutherland
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: