Menu

: java.lang.NoClassDefFoundError: Could not initialize class com.ibm.staf.STAFHandle

Help
2017-01-27
2017-01-27
  • Ganesh Markande

    Ganesh Markande - 2017-01-27

    Hi,

    I am Running STAF on Tomcat Server.. When i tried to create a Handle using JAVA, It threw error message as mentioned in Subject line.

    Note :- I have put the JSTAF.jar file under my lib folder.

    STAFHandle handle = new STAFHandle("MyFirstREST");

     
  • Sharon Lucas

    Sharon Lucas - 2017-01-27

    My guess is that you do not have all the STAF environment variables set in the environment in which you are running the Java program that uses STAF Java APIs. Your CLASSPATH probably does not contain the JSTAF.jar file. Section "2.0 Installation" in the STAF Java User's Guide at http://staf.sourceforge.net/current/STAFJava.htm#Header_Install says:

    STAF's Java support is provided in the JSTAF.jar file (located in either C:\STAF\bin\JSTAF.jar (by default) on Windows systems or /usr/local/staf/lib/JSTAF.jar (by default) on Unix systems. The STAF install adds the JSTAF.jar file to the CLASSPATH environment variable (by default).

    You can test that you have STAF Java support set up correctly by running TestJSTAF as decribed in section "5.0 How to Test STAF Java Support" in the STAF Java User's Guide at http://staf.sourceforge.net/current/STAFJava.htm#Header_TestSTAFJavaSupport. For example, on one of my Linux systems, I verified that the environment variables are set up correctly for STAF and then I ran TestJSTAF to verify that STAF Java support is set up correctly:

    # echo $PATH
    /opt/ibm-java-x86_64-60/bin:/usr/local/staf/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
    # echo $CLASSPATH
    /usr/local/staf/samples/demo/STAFDemo.jar:/usr/local/staf/lib/JSTAF.jar:
    # echo $LD_LIBRARY_PATH
    /usr/local/staf/lib:
    
    # java com.ibm.staf.TestJSTAF local PING PING
    TestJSTAF using STAF handle 113
    RC=0
    Result=PONG
    #
    

    Also see section "7. Environment Variable Settings" in the STAF Installation Guide at http://staf.sourceforge.net/current/STAFInstall.pdf for more information.

    For example if on Linux:
    - PATH must contain the STAF bin directory (e.g. /usr/local/staf/bin)
    - LD_LIBRARY_PATH must contain the STAF lib directory (e.g. /usr/local/staf/lib)
    - CLASSPATH must contain the JSTAF.jar file (e.g. /usr/local/staf/lib/JSTAF.jar)

    Note that the STAF installer creates a STAFEnv script file in the root STAF install location (e.g. /usr/local/staf/STAFEnv.sh) that can be used to set the required environment variables for STAF. You can source setEnv.sh as follows to set the STAF environment variables for the shell that it is run in. For example:

    cd /usr/local/staf
    . ./setEnv.sh
    
     

    Last edit: Sharon Lucas 2017-01-27
  • Ganesh Markande

    Ganesh Markande - 2017-01-30

    Thanks for the reply,

    I fixed the issue.. The issue was even.jar file which was present in my staf.cfg file... I think that was compiled with some older JAVA where as i was using JAVA 1.8 in my new environment... By commenting that section in my staf.cfg file fixed the issue.

     
  • Ganesh Markande

    Ganesh Markande - 2017-01-30

    Please ignore the type... It was event.jar...

     

Log in to post a comment.