Menu

#1320 STAF creates "C:\Program" file when registering Java service

Win32
closed-fixed
Lang::Java (65)
5
2014-07-24
2010-01-15
No

#
snehls
Hi,

since my upgrade to STAF 3.4, STAF creates a File "C:\Program" when it starts up. The file contains the following:

java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)

The Problem ist, that a lot of Applications have problems starting up, because they get confused by "C:\Program" while they are looking for s.th. in "C:\Program Files". It seems to me like STAF itself has some path problems, which results in the wrong location of the logfile.

The problem also occures with STAF 3.3.3. Is this a known problem?

regards
sebastian

#
dave2268

No, this is not a known problem, but it is a bug. When STAFProc starts (and STAF has been installed to a path with spaces, such as C:\Program Files\STAF), and there are Java services configured, when STAFProc tries to determine the Java version used for the service JVM, it is not correctly handling paths with spaces, which is why the C:\Program file is created and contains the output of "java -version". If you examine the Java service JVM log (i.e.C:\Program Files\STAF\data\STAF\lang\java\jvm\STAFJVM1\JVMLog.1) you will see that instead of the expected "java -version" output:

******************************************************************************
*** 20100113-09:32:27 - Start of Log for JVMName: STAFJVM1
*** JVM Executable: java
*** JVM Options : none
*** JVM Version : java version "1.4.2" Java(TM) 2 Runtime Environment,
Standard Edition (build 1.4.2) Classic VM (build 1.4.2, J2RE 1.4.2 IBM Windows 32
build cn142-20070317 (SR8) (J IT enabled: jitc))
*** JVM PID : 3164
******************************************************************************
Registered Extensions for STAX Version 3.4.0:

The "java -version" output is missing if STAF is installed in a path with spaces (such as C:\Program Files\STAF):

******************************************************************************
*** 20100115-08:44:14 - Start of Log for JVMName: STAFJVM1
*** JVM Executable: java
*** JVM Options : -Xmx512m
*** JVM Version :
*** JVM PID : 2900
******************************************************************************
Registered Extensions for STAX Version 3.4.0:

Discussion

  • Sharon Lucas

    Sharon Lucas - 2010-01-15
    • labels: 357172 --> Lang::Java
    • assigned_to: nobody --> slucas
     
  • Sharon Lucas

    Sharon Lucas - 2010-01-15

    Also, found another problem if you register a Java service in your STAF.cfg file and specify to use a JVM executable and the path to the executable contains one or more spaces. For example, if you registered the STAX service in your STAF.cfg file as follows (note the JVM option's path contains a space):

    service STAX library JSTAF execute C:/Program Files/STAF/services/stax/STAX.jar \ OPTION JVMNAME=STAX \ OPTION "JVM=C:/Program Files/STAF/jre/bin/java"

    You'll get the following error when starting STAFProc:

    C:\Program Files\STAF\bin>STAFProc

    Error on Service definition line:

    service STAX library JSTAF execute C:/Program Files/STAF/services/stax/STAX.jar
    OPTION JVMNAME=STAX OPTION "JVM=C:/Program Files/STAF/jre/bin/java"

    Error code: 27
    Reason : Error constructing service, JSTAF, Result: Unable to connect to JVM

    Error in configuration file: C:\Program Files\STAF\bin\STAF.cfg

    C:\Program Files\STAF\bin>

    With the following logged in the JVM log:

    ******************************************************************************
    *** 20100115-17:06:57 - Start of Log for JVMName: STAX
    *** JVM Executable: C:/Program Files/STAF/jre/bin/java
    *** JVM Options : none
    *** JVM Version : 'C:/Program' is not recognized as an internal or external command, operable program or batch file.

     
  • Sharon Lucas

    Sharon Lucas - 2010-01-15

    I fixed both of these problems. I verified that a "C:\Program" file is no longer created when STAF is installed to directory "C:\Program Files\STAF" on a Windows machine and I verified that the JVM logs contain the correct JVM version information.

    Here's a diff of the changes that fix both of these problems:

    Index: lang/java/STAFJavaService.cpp

    RCS file: /cvsroot/staf/src/staf/lang/java/STAFJavaService.cpp,v
    retrieving revision 1.39
    diff -r1.39 STAFJavaService.cpp
    455c455,465
    < // redirect its stdout/stderr to the JVM log file
    ---
    > // redirect its stdout/stderr to the JVM log file.
    > // Make sure the JVM executable and the JVM log name are in double
    > // quotes in case they contain a space and include the entire
    > // command in double quotes.
    > //
    > // Examples:
    > //
    > // "java" -version >> "C:/STAF/data/STAF/lang/java/jvm/STAFJVM1/JVMLog.1" 2>&1
    > //
    > // "C:/Program Files/Java/jre1.5.0_10/bin/java" -version >>
    > // "C:/Program Files/STAF/data/STAF/lang/java/jvm/STAFJVM1JVMLog.1" 2>&1
    457,458c467,480
    < STAFString javaVersionCmd = STAFString("\"") + jvmExec +
    < "\" -version >> " + logName + " 2>&1";
    ---
    > // Only add a double quote to the JVM executable if it isn't
    > // already in double quotes
    >
    > if (!jvmExec.startsWith("\""))
    > jvmExec = STAFString("\"") + jvmExec + "\"";
    >
    > STAFString javaVersionCmd = jvmExec + " -version "
    > ">> \"" + logName + "\" 2>&1";
    >
    > #ifdef STAF_OS_NAME_WIN32
    > // On Windows, need to enclose the entire command in double
    > // quotes
    > javaVersionCmd = STAFString("\"") + javaVersionCmd + "\"";
    > #endif

     
  • Sharon Lucas

    Sharon Lucas - 2010-01-15
    • summary: STAF creates "C:\Program" file at startup --> STAF creates "C:\Program" file when registering Java service
    • status: open --> closed-fixed
     

Log in to post a comment.