Uploaded image for project: 'Commons Daemon'
  1. Commons Daemon
  2. DAEMON-268

jsvc fails to find java home on centos

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 1.0.11
    • 1.0.12
    • Jsvc
    • None
    • Oracle Java JRE 1.7.0_04
      CentOS Linux 6.3, 64-bit

    Description

      Having upgraded to commons-daemon 1.0.11 from 1.0.10, we are now no longer able to start our service because Java Home cannot be located.

      In our particular use case we do not set JAVA_HOME as an environment variable but instead specify it using the -home parameter on the jsvc command line. However I have tried using an environment variable and the result is the same: the jsvc fails to find the Java Home directory.

      Having looked at the source code, I think the error is due to a recent change to home.c. In particular, the following on lines 215 to 221:

      if (path == NULL || *path == '\0' || *path == '/') {
         log_debug("Home not specified on command line, using environment");
         path = getenv("JAVA_HOME");
         if (path == NULL || *path == '\0' || *path == '/') {
             /* guard against empty JAVA_HOME */
             path = NULL;
         }
      }
      

      The use of '==' to compare strings here is incorrect; the strcmp() function should be used instead. Currently, the code will fail if the first character of the path is '/', which is invariably the case on Linux, UNIX or MacOS systems. I suspect the reason that this has not been detected sooner is because MacOS and Ubuntu/Debian have been special-cased elsewhere to hard-code the expected Java Home location.

      For us this is a blocker so we have reverted to using 1.0.10 until it is fixed. We also have a patch which I will attach to this issue shortly.

      Attachments

        1. patch.txt
          0.7 kB
          Richard Lowe

        Issue Links

          Activity

            People

              mturk@apache.org Mladen Turk
              lower29 Richard Lowe
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: