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

jsvc fails to find java home on centos


    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.0.11
    • Fix Version/s: 1.0.12
    • Component/s: Jsvc
    • Labels:
    • Environment:

      Oracle Java JRE 1.7.0_04
      CentOS Linux 6.3, 64-bit


      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.


        1. patch.txt
          0.7 kB
          Richard Lowe

          Issue Links



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


                • Created: