Menu

Running STAFProc from java

Help
soum
2005-10-05
2013-06-12
  • soum

    soum - 2005-10-05

    Hi,
        I am Trying to invoke the STAFProc.exe from java. This is because I want STAF to be run as a demon service and I donot want the STAF initialised window to be displayed to the user. In order to achive this I am using the following code:
         Runtime.getRuntime().exec("STAFProc.exe");

    This starts the STAFProc.exe succesfully with out displaying the STAF initialised window. STAF local ping ping command returns pong.
    But when I try to register the STAX service and the STAFEvent service in the STAF.cfg, it throws me the following error:

    Machine          : dasso03-2kst01.ca.com
    Machine nickname : dasso03-2kst01.ca.com
    Startup time     : 20051005-11:26:11
    Error initializing service, STAX, RC: 27, Result: Error initializing service, JSTAF, Result: java.lang.NoSuchFieldError: fRecognizedFeatures

    When I start the STAFProc.exe directly by double clicking on it with the same STAF.cfg it works fine. That is the STAF is initialised properly.

    I donot want to install STAF as a windows servise as described in the STAF user guide. This is because I am looking for a platform independent solution for this.

    Can you please tell me how to go about this problem?

    Thanks a lot in advance.
    Regards
    Soum

     
    • Sharon Lucas

      Sharon Lucas - 2005-10-05

      Are you sure you are running STAFProc in the same environment?  That is, what is the version of Java that the STAX service is using?

      Is there any additional information in the JVMLog.1 file? 

      The JVM log files are stored in the {STAF/DataDir}/lang/java/jvm/<JVMName> directory and contain JVM start information such as the date/time when the JVM was started, the JVM executable, and the J2 options used to start the JVM. In addition, it contains any other information logged by the JVM, including any errors that may have occurred while the JVM was running. The current JVM log file is named JVMLog.1

       
    • soum

      soum - 2005-10-06

      Hi,
         Please tell me how to make sure that STAFProc is using the same environment or not. I did not change any environment programatically so The STAFProc is suppose to inharit the invoking java class's environment right?
        I have JRE 1.5 and JDK 1.5 installed in my machine.
      Please tell me how to find out what version of the java the STAX service is using?

      My STAF.cfg looks like this:
      # Turn on tracing of internal errors and deprecated options
      trace enable tracepoints "error deprecated"

      # Enable TCP/IP connections
      interface tcp library STAFTCP

      # Set default local trust
      trust machine local://local level 5

      # Default Service Loader Service
      serviceloader library STAFDSLS

      SERVICE STAX LIBRARY JSTAF EXECUTE C:\Staf\services\stax\STAX.jar
      SERVICE EVENT LIBRARY JSTAF EXECUTE C:\Staf\services\stax\STAFEvent.jar

      Here is the JVM log file:

      ******************************************************************************
      *** 20051005-11:40:48 - Start of Log for JVMName: STAFJVM1
      *** JVM Executable: java
      *** JVM Options   : none
      ******************************************************************************
      java.lang.NoSuchFieldError: fRecognizedFeatures
          at org.apache.xerces.parsers.XML11Configuration.<init>(Unknown Source)
          at org.apache.xerces.parsers.XML11Configuration.<init>(Unknown Source)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
          at java.lang.reflect.Constructor.newInstance(Unknown Source)
          at java.lang.Class.newInstance0(Unknown Source)
          at java.lang.Class.newInstance(Unknown Source)
          at org.apache.xerces.util.ObjectFactory.newInstance(ObjectFactory.java:296)
          at org.apache.xerces.util.ObjectFactory.createObject(ObjectFactory.java:224)
          at org.apache.xerces.util.ObjectFactory.createObject(ObjectFactory.java:119)
          at org.apache.xerces.parsers.DOMParser.<init>(DOMParser.java:109)
          at com.ibm.staf.service.stax.STAX.init(STAX.java:246)
          at com.ibm.staf.service.STAFServiceHelper.initService(STAFServiceHelper.java:290)
      In In STAFThreadManager::workerThread() outer try block:
      Caught STAFException
      Name      : STAFInvalidObjectException
      Location  :
      Text      : STA
      Error code: 41

      Please tell me how to overcome this problem.
      Thanks in advance
      Regards
      Soum

       
      • Sharon Lucas

        Sharon Lucas - 2005-10-06

        I started STAFProc (using a STAF.cfg file that registers the STAX and Event services) via a Java program like ours and STAF, as well as the STAX and Event services registered fine.

        Since the error message is coming from Xerces, I suspect that you have an xerces jar file (e.g. xercesImpl.jar or XMLParserAPIs.jar) in your CLASSPATH that is overridding the version of Xerces that STAX needs and provides as nested jar files.  Please check your CLASSPATH environment variable to seeif you have any of the Xerces jar files (xercesImpl.jar, xmlParserAPIs.jar) and, if so, remove them from the CLASSPATH and restart STAFProc.

        Note that STAFProc usee whatever environment you have in the command prompt window where you running your Java program from.

        You can do a "STAF local VAR LIST" command to see the STAF/Env/Path, STAF/Env/ClassPath, etc. environment variables that STAF is using.

        If you don't override the JVM that the STAX service uses (by specifying OPTION JVM=xxx when registering the STAX service) then the STAX service will use whatever java executable is in your path.  You can run "java -version" from the command prompt window where you are running your Java program that starts STAF to see the version of Java that the STAX service will use.

         

Log in to post a comment.