You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Mladen Turk (JIRA)" <ji...@apache.org> on 2012/11/30 14:37:58 UTC

[jira] [Commented] (DAEMON-268) jsvc fails to find java home on centos

    [ https://issues.apache.org/jira/browse/DAEMON-268?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13507322#comment-13507322 ] 

Mladen Turk commented on DAEMON-268:
------------------------------------

Right, seems we'll be releasing 1.0.12 pretty soon. It's a serious regression.

-    if (path == NULL || *path == '\0' || *path == '/') {
+    if (path == NULL || strcmp(path, "") == 0 || strcmp(path, "/") == 0) {

Well, strcmp should be used only for the last part. strcmp(path, "") is the same as *path == '\0'

                
> jsvc fails to find java home on centos
> --------------------------------------
>
>                 Key: DAEMON-268
>                 URL: https://issues.apache.org/jira/browse/DAEMON-268
>             Project: Commons Daemon
>          Issue Type: Bug
>          Components: Jsvc
>    Affects Versions: 1.0.11
>         Environment: Oracle Java JRE 1.7.0_04
> CentOS Linux 6.3, 64-bit
>            Reporter: Richard Lowe
>            Assignee: Mladen Turk
>            Priority: Blocker
>             Fix For: 1.0.12
>
>         Attachments: patch.txt
>
>
> 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|http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/native/unix/native/home.c?r1=1205952&r2=1412037&diff_format=h]. In particular, the following on lines 215 to 221:
> {code}
> 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;
>    }
> }
> {code}
> 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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira