staf 3.4.5 java error on rhel 6

Help
2011-06-28
2013-06-12
  • Gerd Radecke
    Gerd Radecke
    2011-06-28

    Hi,

    I'm trying to run Staf 3.4.5 on the following system with no success.

    # uname -a
    Linux box 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
    # java -version
    java version "1.6.0_17"
    OpenJDK Runtime Environment (IcedTea6 1.7.4) (rhel-1.21.b17.el6-x86_64)
    OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
    

    I installed the version with the bundled JVM, so I'm not certain if the openjdk is even relevant here.

    I can start the STAFProc, and it doesn't give any errors, yet running anything on the staf client returns RC:21.

    # tail nohup.out
    Machine          :  box
    Machine nickname : box
    Startup time     : 20110628-05:19:31
    STAFProc version 3.4.5 initialized
    # staf local ping ping
    Error registering with STAF, RC: 21
    

    Testing the java standalone throws the following error, which I couldn't find any more information about:

    # java com.ibm.staf.TestJSTAF local MISC VERSION
    com.ibm.staf.STAFException: 
        at com.ibm.staf.STAFHandle.STAFRegister(Native Method)
        at com.ibm.staf.STAFHandle.<init>(STAFHandle.java:35)
        at com.ibm.staf.TestJSTAF.main(TestJSTAF.java:36)
    (funny enough - the command works from remote:
    # java com.ibm.staf.TestJSTAF remote.box.com MISC VERSION
    TestJSTAF using STAF handle 14
    RC=0
    Result=3.4.5
    )
    

    I realized that on my other testbox, after starting STAF, 3 processes run:

    26114 pts/3    Sl     0:05 /opt/staf/bin/STAFProc
    26133 pts/3    S      0:00 sh -c "java"  -Xmx384m com.ibm.staf.service.STAFServiceHelper STAFJVM1
    26134 pts/3    Sl     0:04 java -Xmx384m com.ibm.staf.service.STAFServiceHelper STAFJVM1
    

    while on the one where it's not working I just have:

     4924 pts/1    Sl     0:00 /usr/local/staf/bin/STAFProc
    

    Any help with troubleshooting this is appreciated :) I'm quite new to STAF.

     
  • Sharon Lucas
    Sharon Lucas
    2011-06-28

    How are you starting STAFProc?  Are you starting it as follows:

    # cd /usr/local/staf
    # ./startSTAFProc.sh

    When you submit a STAF service request to machine "local", then the STAF Local IPC Connection Provider is used. When you submit a STAF service request to a host name or IP address then the STAF TCP/IP Connection Provider (tcp or ssl) is used.  So, it appears there is a problem using the STAF Local IPC ConnProvider as you are getting RC 21 when submitting any "local" request.  Note that submitting a request to the MISC service on the "local" machine via a Java program is failing for the same reason.

    The help for RC 21 says:

    # STAF local HELP ERROR 21
    Response


    Description: STAF not running
    Details    : This indicates that STAFProc is not running on the local machine
    with the same STAF_INSTANCE_NAME (and/or the same STAF_TEMP_DIR if on a Unix
    machine).

    Notes:
    1. If the STAF_INSTANCE_NAME environment variable is not set, it defaults
       to "STAF".
    2. On Unix, if the STAF_TEMP_DIR environment variable is not set, it defaults
       to "/tmp".  This environment variable is not used on Windows.
    3. This error can also occur when submitting a request using the local IPC
       interface on a Unix machine if the socket file that the local interface
       uses has been inadvertently deleted.
    4. To get more information on this error, set special environment variable
       STAF_DEBUG_21=1 and resubmit your local STAF service request.

    So, are the following environment variables set and if so, what are they set to?  Run the following commands from the same terminal where you are starting STAFProc;

    echo $STAF_INSTANCE_NAME
    echo $STAF_TEMP_DIR

    If STAF_TEMP_DIR is not set, it defaults to /tmp.  Make sure that the /tmp directory (or whatever directory you are using for STAF_TEMP_DIR) exists and that the user that STAFProc was started as has write access to this tmp directory.  Provide the output of:   ls -la /tmp  (assuming you are using the default /tmp directory)

    Also, the STAF FAQ has an entry about another possible cause of RC 21 on Unix systems if you are starting STAF during the reboot of a Unix system.  See http://staf.sourceforge.net/current/STAFFAQ.htm#d0e1263.

     
  • Gerd Radecke
    Gerd Radecke
    2011-06-28

    Just to answer a few questions first :)

    This is how I start staf - started it automatically on reboot yet.

    # pwd
    /usr/local/staf
    # ./startSTAFProc.sh 
    # nohup: appending output to `nohup.out'
    # staf local misc version
    Error registering with STAF, RC: 21
    # echo $STAF_INSTANCE_NAME
    # echo $STAF_TEMP_DIR
    # export STAF_INSTANCE_NAME=STAF_ncm_134
    # echo $STAF_INSTANCE_NAME
    STAF_ncm_134
    # staf local misc version
    Response
    --------
    3.4.5
    

    So somehow STAFEnv.sh doesn't set STAF_INSTANCE_NAME as it should, yet the code looks correct to me:

    # cat STAFEnv.sh 
    #!/bin/sh
    # STAF environment variables
    PATH=/usr/local/staf/bin:${PATH:-}
    LD_LIBRARY_PATH=/usr/local/staf/lib:${LD_LIBRARY_PATH:-}
    CLASSPATH=/usr/local/staf/lib/JSTAF.jar:/usr/local/staf/samples/demo/STAFDemo.jar:${CLASSPATH:-}
    STAFCONVDIR=/usr/local/staf/codepage
    if [ $# = 0 ]
    then
        STAF_INSTANCE_NAME=STAF_ncm_134
    else
        if [ $1 != "start" ]
        then
            STAF_INSTANCE_NAME=$1
        else
            # Ignore "start" STAF instance name
            STAF_INSTANCE_NAME=STAF_ncm_134
        fi
    fi
    export PATH LD_LIBRARY_PATH CLASSPATH STAFCONVDIR STAF_INSTANCE_NAME
    

    looking at this,  for STAF_INSTANCE_NAME to remain empty, $# would have to be != 0 and yet $1 is empty - which leaves me wondering: where does this empty string argument come from?

    (aside from that - something that I find a little ironic:

    # staf local help error 21
    Error registering with STAF, RC: 21
    
     
  • Sharon Lucas
    Sharon Lucas
    2011-06-28

    I don't know why STAFEnv.sh isn't working correctly on your Linux machine.  No one else has reported a problem.  We start STAFProc this way just fine on all of our Linux machines.  You could just manually update your STAFEnv.sh file.

    IBM Java 1.4.2 works correctly (http://www-106.ibm.com/developerworks/java/jdk/index.html)

    3.1.12.

    Explain RC 21 when running staf local ping ping on Unix platforms.

    When executing STAFEnv.sh during system startup on Unix platforms, it is possible to inadvertently pass "start" as the parameter to STAFEnv.sh (and so STAFProc is using that as the instance name when it starts). In this scenario, if you run staf <unix-machine> var list from another machine and examine the value of STAF/Config/InstanceName, the value will be set to "start". So, even though "echo $STAF_INSTANCE_NAME" is set to "STAF" as expected when you run "staf local ping ping", the value that STAFProc is using does not match, and so you get an RC 21.

    Perhaps the STAF FAQ entry that I mentioned provides some light on this.  See question "3.1.12. Explain RC 21 when running staf local ping ping on Unix platforms" at http://staf.sourceforge.net/current/STAFFAQ.htm#d0e1263 which says:

    If this is the case, you can resolve the problem by adding a "shift" command to the start section of the STAF startup script just before STAFEnv.sh is called. That way, the parameters are decremented from 1 to 0. So you would have something like:

    'start')
            if ; then
                    . /etc/rc.config.d/staf
            fi
            if ; then
                    shift
                    . /usr/local/staf/STAFEnv.sh
                    /bin/nohup STAFProc 2>error &
            fi
            ;;

    Any request submitted to "local" (even a HELP service request) will fail with RC 21 if STAF_INSTANCE_NAME is not being set.. I meant that you could submit this request from another STAF machine whose local interface is working (or see the STAF User's Guide to get help for RC 21).

    Note that you should probably want set STAF_INSTANCE_NAME to STAF not STAF_nom_134, unless you are running multiple versions of STAFProc on a single machine (then each instance of STAFProc running needs to use a unique STAF_INSTANCE_NAME).

     
  • Gerd Radecke
    Gerd Radecke
    2011-06-28

    Note that you should probably want set STAF_INSTANCE_NAME to STAF not STAF_nom_134, unless you are running multiple versions of STAFProc on a single machine (then each instance of STAFProc running needs to use a unique STAF_INSTANCE_NAME).

    I'll do that - thanks for your fast help.