This is where you should look if you have a question about STAF V2, STAX V1, or an external STAF V2 service.
For questions about STAF V3, STAX V3, or an external STAF V3 service,. see the STAF V3 FAQ
1. General Information | |||
| |||
1.1. | What is STAF? | ||
STAF stands for "Software Testing Automation Framework. As its name indicates, STAF is an automation framework. It is intended to make it easier to create and manage automated testcases and test environments. STAF externalizes its capabilities through services. A service provides a focused set of functionality, such as, Logging, Process Invocation, etc. STAFProc is the process that runs on a machine, called a STAF Client, which accepts requests and routes them to the appropriate service. These requests may come from the local machine or from another STAF Client. Thus, STAF works in a peer environment, where machines may make requests of services on other machines. STAF was designed with the following points in mind:
| |||
1.2. | What operating systems are supported by STAF? | ||
STAF 2.5 is supported on the following operating systems:
If you need support for another operating system, open a feature request on the STAF SourceForge web site.
If you can't wait, port STAF to your favorite operating system yourself since STAF is open source.
| |||
1.3. | Where can I get STAF? | ||
STAF software, information, documentation, etc. can be found at the STAF SourceForge web site. | |||
1.4. | Is STAF Open Source? | ||
Yes! STAF is released under the CPL (Common Public License) V1.0. | |||
1.5. | What documentation exists for STAF? | ||
The following documents can be found at the STAF SourceForge web site.
| |||
1.6. | How do I get on/off STAF mailing lists? | ||
Go to the STAF Mailing Lists web page and click on Subscribe or Unsubscribe for the STAF mailing list that you want to be added to or removed from. | |||
1.7. | How do I get help? | ||
You can submit questions using the STAF Mailing Lists and the STAF Discussion Forums on SourceForge. If you are an IBMer, you may use the following IBM Internal Newsgroup to submit questions for STAF, STAX, and its services:
You can also get help about a STAF service's request syntax by using the following command: STAF local service HELP This will return the available options for the <service>
You can find out more information about STAF error codes by using the following command: STAF local HELP ERROR 7 This will return detailed information about error code 7.
| |||
1.8. | How do I request a feature for STAF? | ||
To request a feature (or browse a list of requested features), click here. | |||
1.9. | Why isn't STAF written in Java? | ||
| |||
1.10. | What is the performance overhead of running STAF? | ||
As a general rule, STAF takes up very little system resources. A typical STAF installation is about 10-30 MB (depending on whether you use the installer with the integrated JVM). STAF's in-memory size (without any additional external services) is about 2.5-5 MB (depending on the platform). On an idle STAF system (i.e., one in which there are no requests currently being handled by STAF) STAF consumes 0% CPU on a Windows system and a VERY limited amount on unix systems. On unix, we have a thread which wakes up once a second to see if any STAF processes have completed. STAF was designed to consume as little system resources as possible, as we know that people want their test systems as close to clean-room conditions as possible. | |||
1.11. | How do I interact with STAF? | ||
You can interact with STAF from many languages (Java, C, C++, Rexx, Perl, Tcl) and from the command line/shell prompt. See the "API Reference" and "Commands" sections in the STAF User's Guide for more information. If you need support for another language, open a feature request on the STAF SourceForge web site. If you can't wait, provide support for your favorite language yourself since STAF is open sourced. | |||
2. How-to Questions | |||
| |||
2.1. Installation/Configuration | |||
| |||
2.1.1. | How do I install STAF? | ||
STAF provides its own installation program which uses InstallShield Multi-Platform for supported platforms. On Unix platforms, we also provide a shell script-based installation mechanism. See the Installation section in the STAF User's Guide for detailed instructions on how to install STAF. You can find which platforms are supported on InstallShield Multi-Platform at http://www.installshield.com/imp/info/specifications.asp | |||
2.1.2. | How do I install STAF in silent mode? | ||
Here are the commands to install STAF in silent mode (these examples are for Win32): If using the InstallShield MultiPlatform executable:
C:\temp>STAF250-setup-win32 -silent
If using the InstallShield MultiPlatform Jar file:
C:\temp>java -jar STAF250-setup-win32.jar -silent
To override the default location where STAF is installed during a silent installation, you can specify the following option (note that this option is only supported on STAF 2.5.0 or higher):
C:\temp>STAF250-setup-win32 -silent -W stafinstalldirectory.defaultInstallLocation="C:\tools\staf"
| |||
2.1.3. | How do I configure STAF? | ||
STAF is configured through a text file called the STAF Configuration File. This file may have any name you desire, but the default is STAF.cfg. The STAF configuration File is read and processed line by line. The various configuration options are described in the Configuration section in the STAF User's Guide. | |||
2.2. Starting STAF | |||
2.2.1. | How do I make STAF start automatically during reboot on Unix platforms? | ||
Each Unix platform has a different method to start executables automatically during reboot. On Linux platforms, add the following lines to the /etc/rc.d/rc.local (or, if on SuSe, /etc/init.d/boot.local) file (substituting your specific locations where STAF and Java are installed): PATH=/usr/local/staf/bin:/jdk1.3.1/bin:$PATH; export PATH CLASSPATH=/usr/local/staf/lib/JSTAF.jar:$CLASSPATH; export CLASSPATH STAFCONVDIR=/usr/local/staf/codepage; export STAFCONVDIR LD_LIBRARY_PATH=/usr/local/staf/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH /usr/local/staf/bin/STAFProc & You may get the following error message: STAFProcess::processMonitorThread: error opening /dev/tty, errno: 6 But STAFProc does start despite this message, and accepts requests. | |||
2.2.2. | How do I start STAF as a Windows service? | ||
On Windows, when the machine fails and/or is rebooted, STAF is unavailable for remote commands until a user logs in and starts it. As an solution, you can configure the STAF process as a Windows service that will run automatically when the machine boots. Procedure 1. Starting STAF as a Windows Service These instructions assume you have copied INSTSRV.EXE and SVRANY.EXE (available from the Windows Resource Kit) into C:\WINNT\SYSTEM32 and you have users connecting through Remote Desktop Client. These instructions are for Windows 2000 and later.
Problems and Solutions when Starting STAF as a Service: Problem: If a user logs on before the STAF process (STAFproc) has initialized, it is possible that they still receive the error 'Error registering with STAF, RC: 21' even after the service has started.
Solution: Stop and restart the service with due care as others might already be using it. net stop staf net start staf
Problem: STAF should not be started or shutdown with the commands on the start menu when STAF is configured as a service.
Solution: The service can be restarted by suitably authorized user from the command line with: net stop staf net start staf
The service can be restarted from the services panel of the management console by right clicking and selecting stop and then right clicking and selecting start.
Problem: STAF is still started (and fails) when the user who installed it logs in.
Solution: Delete STAF from Start > Programs > Startup folder
| |||
2.3. PROCESS Service | |||
2.3.1. | How do I redirect output from a process started by STAF? | ||
You can't use the command line redirection symbols, such as '>', with STAF. They won't work. However, STAF's PROCESS service provides several redirection options, namely STDIN, STDOUT, STDOUTAPPEND, STDERR, and STDERRAPPEND, depending on what (and how) you want to redirect. For example, to start shell script tc3.sh and redirect its standard output to /tmp/tc3.out: STAF local PROCESS START COMMAND tc3.sh STDOUT /tmp/tc3.out | |||
2.3.2. | How do I run a complex command that I can type at a shell (command) prompt via STAF? | ||
The PROCESS service has a SHELL parameter which specifies that COMMAND should be executed as though you were at a shell prompt. This allows complex commands involving pipelines to be readily executed. Note, if COMMAND and PARMS are both specified they will be concatenated with a space between them, and the resulting string is what will be executed.
| |||
2.3.3. | How do I use a static handle to have multiple programs access variables and log data? | ||
If you have a program (PROG-A) that creates a static handle, and you want to start another program (PROG-B) using the STAF start command, such that PROG-B can create variables and a log using that same handle. The problem is that each program has to know the number of the static handle in order to use it. You can do this via an environment variable. So, from PROG-A, you could do something like: request = 'start command cmd.exe parms "/c PROG-B" env STAFHANDLE='staticHandle call STAFSubmit 'local', 'process', request
Then, PROG-B can pull the static handle from the environment variable. | |||
2.4. LOG Service | |||
2.4.1. | How do I make each application have its own STAF log file? | ||
Use HANDLE logs instead of GLOBAL logs. With HANDLE logs each application will get a physically separate log file. HANDLE logs keep separate logs for each process even if the processes are using the same log names. The downside to HANDLE logs is you need to remember the handles you were using, so that you can query them. For example if you log data to a handle log, like so:
STAF local log LOG HANDLE LOGNAME testit LEVEL info MESSAGE hello
then you can query it like so:
STAF local log QUERY MACHINE m1 HANDLE h1 LOGNAME testit
In this request you need to know m1 (which should be your machines name) and h1 which you won't know until your program is executed.
To facilitate HANDLE based logs, it is probably a good idea for programs using them to write their name and handle to a GLOBAL log so that you can determine which HANDLE logs you need to query.
| |||
2.4.2. | How do I view a STAF log as it appears to be in some weird format? | ||
This is the expected format for STAF logs (they are binary files, not text files). As a general rule you should use the LOG service itself to look at the logs. For example:
STAF local log query global logname stresstst
You can redirect that to another file, which will be in text format, if you want. You can also use the FmtLog utility (shipped with STAF) which will read a log file and format and write the data to an output file in a readable format. | |||
2.5. HTTP Service | |||
2.5.1. | Does the HTTP Service retain session information across multiple requests? | ||
Yes. Version 2.0 (and later) of the HTTP service provides the ability to group requests to the HTTP service together in a session. Performing requests in a session provides the ability simulate a browsing experience. Since a session provides memory about the last request it is possible to manipulate cookies, login into secure web sites, and interact with form and link html elements that are returned from requests. | |||
2.6. STAX Service | |||
| |||
2.6.1. | How do I access system date and time in a STAX job? | ||
You can either use the python libraries or the java libraries. Here is a STAX job which shows both approaches: Example 1. Accessing system date and time via Python libraries and Java libraries <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE stax SYSTEM "stax.dtd"> <stax> <defaultcall function="test"/> <function name="test"> <sequence> <!-- get the python date --> <script> from time import localtime, strftime currenttime = strftime("%a, %d %b %Y %H:%M:%S", localtime()) </script> <message>'Python time: %s' % currenttime</message> <!-- get the java date --> <script> from java.util import Calendar, Date from java.text import SimpleDateFormat formatter = SimpleDateFormat("yyyy.MM.dd G 'at' hh:mm:ss a zzz") currentTimestamp = Date() dateString = formatter.format(currentTimestamp) </script> <message>'Java time: %s' % dateString<</message> </sequence> </function> </stax> | |||
2.6.2. | How do I search for multiple strings in testcase output files in STAX? | ||
You can use the Python re library to search for multiple strings in testcase output files. For example, if you have a testcase output file c:/temp/test.txt: Example 2. Contents of testcase output file c:/temp/test.txt ********************************* Top of Data ********************************** ---------+---------+---------+---------+---------+---------+---------+---------+ SET CURRENT SQLID='DBTIFAHC'; ---------+---------+---------+---------+---------+---------+---------+---------+ DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0 ---------+---------+---------+---------+---------+---------+---------+---------+ SELECT * FROM SPA_FI_REGISTRY; ---------+---------+---------+---------+---------+---------+---------+---------+ FI_ID AVLBLTY_STATUS UPDATE_USER_ID UPDATE_TMSTP ---------+---------+---------+---------+---------+---------+---------+---------+ IBANKA S STCCICS 2003-07-11-08.38.37.638163 DSNE610I NUMBER OF ROWS DISPLAYED IS 1 DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100 ---------+---------+---------+---------+---------+---------+---------+---------+ -- INSERT INTO IFS_SESSN_ACTIVE -- (USR_ID, FI_ID,SERV_ID,SESSN_NBR,IP_ADDR,SESSN_STRT_TMSTP, -- SESSN_END_TMSTP,SESSN_ST_CODE, SESSN_MQ_QUALIFIER,CHK_DUPL_TXN, -- SERV_INST_NBR) F1=Help F2=Split F3=Exit F5=Rfind F7=Up F8=Down F9=Swap F10=Left F11=Right F12=Cancel SPUFI SSID: DB71 ===> Enter the input data set name: (Can be sequential or partitioned) 1 DATA SET NAME ... ===> 'MONICA1.IFSSCCAH.SPUFI.CNTL(SELECT)' 2 VOLUME SERIAL ... ===> (Enter if not cataloged) 3 DATA SET PASSWORD ===> (Enter if password protected) * DSNE361I SPUFI PROCESSING COMPLETE * Here's a sample STAX job that searches for 3 sets of strings in the test.txt file. Notice that when you specify the string text, you need to escape, with a backslash, any non-alphanumeric characters (such as spaces, dots, comma, equals, greater/less than, parenthesis...). You can find a Howto on Regular Expressions at http://www.amk.ca/python/howto/regex/. Example 3. Using Python re (regular expression) module to do string matches <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE stax SYSTEM "stax.dtd"> <stax> <defaultcall function="test"/> <function name="test"> <sequence> <stafcmd> <location>'local'</location> <service>'fs'</service> <request>'get file c:/temp/test.txt'</request> </stafcmd> <script> import re result = STAFResult searchre = r"""(?mx) ^.* ^.*?IBANKA.*? ^.* ^.*?1\ \ DATA\ SET\ NAME\ \.\.\.\ \=\=\=\>\ \'MONICA1\.IFSSCCAH\.SPUFI\.CNTL\(SELECT\)\'.*? ^.* ^.*?DSNE361I\ SPUFI\ PROCESSING\ COMPLETE.*? ^.*""" </script> <if expr='re.match(searchre, result) != None'> <message>'Pass'</message> <else> <message>'Fail'</message> </else> </if> </sequence> </function> </stax> | |||
2.6.3. | How do I access STAF global variable values via a STAX job? | ||
The STAF variables have to be resolved using either the VAR service through a <stafcmd> or using the STAXUtilImportSTAFVars function from the STAXUtil.xml file (provided with the STAX download in the library subdirectory of the STAX installroot). Example 4. Using <stafcmd> to call the var service <stafcmd> <location>'local'</location> <service>'var'</service> <request>'resolve {STAF/Config/STAFRoot}'</request> </stafcmd> <script>stafRoot=STAFResult</script> Example 5. Using the STAXUtilImportSTAFVars function <call function="'STAXUtilImportSTAFVars'"> [ {'STAF/Env/STAFDir': 'mySTAFDir', 'STAF/Version': 'mySTAFVersion'}, 'machA' ] </call> and the resulting STAX variables could be: mySTAFDir = 'C:\STAF' mySTAFVersion = '2.5.0' See STAXUtil.html for full details. | |||
2.6.4. | How do I use the <stopusing> element in a STAX job that runs on both Windows and Unix? | ||
You can first determine whether the machine is Windows or non-Windows, set a variable to the STOPUSING option that you want to use on that operating system, and then use that variable in the <stopusing> element. Here is a sample STAX job: Example 6. Setting the <stopusing> value based on the operating system <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE stax SYSTEM "stax.dtd"> <stax> <defaultcall function="test"/> <function name="test"> <sequence> <stafcmd> <location>'local'</location> <service>'var'</service> <request>'resolve {STAF/Config/OS/Name}'</request> </stafcmd> <script> import re osname = STAFResult </script> <if expr='re.search("^win", osname.lower()) != None'> <script>stopusing = 'WM_CLOSE'</script> <else> <script>stopusing = 'SIGKILLALL'</script> </else> </if> <process> <location>'local'</location> <command>'java'</command> <stopusing>stopusing</stopusing> </process> </sequence> </function> </stax>
| |||
2.6.5. | Does a STAX process element use the workdir element as the path to the command? | ||
No. The STAF User's Guide, section 8.10.2 (PROCESS START) says: COMMAND specifies the actual command that you want to start. If the path to the command is not specified, the system PATH will be searched for the command. So, if the path to the command is not specified in the <command> element, the system PATH is searched. Just specifying the <workdir> will not make it use the workdir as the path and you'll get RC 10 (Base operating system error) because it couldn't find the command executable. The following <process> element specifies the path (assigned to variable testdir) to the test1.exe executable since it's not in the system PATH: Example 7. Specifying the path to the executable in the <command> <script> clientname = 'machineA.austin.ibm.com' testdir = 'C:/test' </script> <process> <location>clientname</location> <command>'%s/test1.exe' % (testdir)</command> <workdir>testdir</workdir> </process>
| |||
2.6.6. | How do I use STAF and STAX to boot and shutdown VMWare images on my test machines? | ||
You can use STAF/STAX to boot VMWare images and then execute tests on the VMWare images. Below is a example that demonstrates how to do this. The "startvmware" function boots a VMWare image. Note that it's <function-prolog> has important information on how to configure your VMWare image to work correctly with STAF/STAX. The "stopvmware" function shuts down and powers off a VMWare image. The "main" function shows how you call the vmware functions. In your main function, after the VMWare image has booted (you would need to wait for an appropriate amount of time and do a STAF PING to the machine to determine that it's up and running), you would begin running your tests on the VMWare image. Example 8. Using STAF/STAX to boot VMWare images and then execute tests <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE stax SYSTEM "stax.dtd"> <stax> <defaultcall function="main"/> <function name="main" scope="local"> <parallel> <block name="'Boot up VMWare image'"> <call function="'startvmware'"> { 'image': 'c:/vmware/winxp/Windows-XP-Professional.vmx', 'timeout' : '5m', 'imagehostname' : 'abcdef', 'imagename' : 'Windows XP Professional' } </call> </block> <block name="'Release this block to shutdown the VMWare image'"> <sequence> <hold/> <call function="'stopvmware'"> { 'imagehostname' : 'abcdef', 'shutdown' : 'shutdown -s -f -t 0' } </call> </sequence> </block> </parallel> </function> <function name="startvmware" scope="local"> <function-prolog> Starts a VMWare image, and attempts to do a STAF PING to the VMWare image. Your VMWare image needs to be configured so that there are no popups displayed when the VMWare image starts (for example, messages about Disk Drive warnings, etc), and that the image is set up to automatically log in. Also, the machine must be configured to start STAF automatically. Also, you must have the following 2 lines in your VMWare image's .vmx file: gui.exitOnCLIHLT = "TRUE" gui.exitAtPowerOff = "TRUE" Note that you should avoid terminating any blocks that are running a VMWare image, as that will kill the VMWare image without it being shutdown. Instead, you should manually shutdown and power off the VMWare image, or call the "terminatevmware" [not yet implemented] function. You should use Bridged network connections for VMWare images to work correctly with this function. </function-prolog> <function-map-args> <function-optional-arg name="machine" default="'local'"> The machine on which the VMWare image is to be started. The default is 'local'. </function-optional-arg> <function-optional-arg name="vmwarebin" default="'c:/Program Files/Vmware/VMware Workstation/vmware.exe'"> The VMWare executable file. If the VMWare executable is not in the VMWare system's PATH, then the file must be fully qualified. The default is 'c:/Program Files/Vmware/VMware Workstation/vmware.exe'. </function-optional-arg> <function-required-arg name="image"> The fully qualified VMWare .vmx file for the VMWare image. Note that the VMWare executable does not permit spaces in the file name of the vmx file. </function-required-arg> <function-required-arg name="imagehostname"> The hostname for the VMWare image. </function-required-arg> <function-optional-arg name="timeout" default="'10m'"> The timeout value for when the function should stop attempting to STAF PING the VMWare image. The default is 10 minutes. The STAF PING to the VMWare image will be attempted every 30 seconds, up to the timeout value. </function-optional-arg> <function-optional-arg name="imagename" default='image'> The name of the VMWare image. The default is the argument specified for image. </function-optional-arg> </function-map-args> <parallel> <process name="'VMWare Image %s ' % imagename"> <location>machine</location> <command>vmwarebin</command> <parms>'-x -q %s' % image</parms> <!-- -x powers on automatically, -q exits at power off --> <stdout>'out.txt'</stdout> <stderr mode="'stdout'"/> <returnstdout/> </process> <sequence> <script>contacted = 0</script> <timer duration='timeout'> <loop while="contacted == 0"> <sequence> <stafcmd name="'Delaying for 30 seconds'"> <location>'local'</location> <service>'delay'</service> <request>'delay 30000'</request> </stafcmd> <stafcmd name = "'Attempt to ping %s' % imagehostname"> <location>imagehostname</location> <service>'ping'</service> <request>'ping'</request> </stafcmd> <if expr="RC == 0"> <sequence> <script>contacted = 1</script> <message>'Machine %s is up and running with VMWare image %s' % (imagehostname, imagename)</message> <log>'Machine %s is up and running with VMWare image %s' % (imagehostname, imagename)</log> </sequence> </if> </sequence> </loop> </timer> <if expr="RC != 0"> <sequence> <message>'Machine %s with VMWare image %s was not successfully started RC: %s' % (imagehostname, imagename, RC)</message> <log>'Machine %s with VMWare image %s was not successfully started RC: %s' % (imagehostname, imagename, RC)</log> </sequence> </if> </sequence> </parallel> </function> <function name="stopvmware" scope="local"> <function-prolog> Stops a VMWare image </function-prolog> <function-map-args> <function-required-arg name="imagehostname"> The hostname for the VMWare image. </function-required-arg> <function-required-arg name="shutdown"> The command used to shut down the OS. </function-required-arg> </function-map-args> <sequence> <script> from com.ibm.staf import STAFUtil </script> <stafcmd> <location>imagehostname</location> <service>'process'</service> <request>'start async shell command %s' % STAFUtil.wrapData(shutdown)</request> </stafcmd> </sequence> </function> </stax> | |||
2.6.7. | How can I parse an XML file from a STAX job? | ||
A STAX job can parse an XML file using an XML Parser of your choice. Below is a example that demonstrates how to do this using an XML Parser provided with java. This example parses an XML file whose name you specify and also validates the xml file. In this example, it's parsing a STAX xml file so it's using the STAX DTD but you could specify another DTD). This example also provides xml parsing error information, including the line number and xml parsing error message. Example 9. Parsing an XML File from a STAX job <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE stax SYSTEM "stax.dtd"> <stax> <defaultcall function="Main"/> <function name="Main"> <sequence> <!-- Assign the file name of a STAX xml document you want to parse --> <call function="'parseXML'">'c:/dev/src/stax/leTest.xml'</call> <script> document = STAXResult # Change code here to parse the document as you desire. # The code shown here is just an example for parsing a STAX xml document root = document.getDocumentElement() children = root.getChildNodes() msg = '' for i in range(children.getLength()): thisChild = children.item(i); if (thisChild.getNodeType() == Node.ELEMENT_NODE and thisChild.getNodeName() == 'defaultcall'): msg = '%s\nFound defaultcall element' % (msg) elif thisChild.getNodeType() == Node.COMMENT_NODE: # Do nothing continue elif thisChild.getNodeType() == Node.ELEMENT_NODE: msg = '%s\nFound %s element' % (msg, thisChild.getNodeName()) </script> <message>'Some parsed data: %s' % (msg)</message> <log>'Some parsed data: %s' % (msg)</log> </sequence> </function> <!-- ******************************************************************* --> <!-- Following function is used to parse an XML file and return the DOM --> <!-- document object --> <!-- ******************************************************************* --> <function name="parseXML" scope="local"> <function-list-args> <function-required-arg name="xmlFileName"> Name of file containing XML to be parsed </function-required-arg> </function-list-args> <sequence> <!-- Parse the XML --> <script> factory = DocumentBuilderFactory.newInstance(); factory.setValidating(1) factory.setIgnoringElementContentWhitespace(0) try: parseError = 0 builder = factory.newDocumentBuilder() resolver = ParserResolver() builder.setEntityResolver(resolver) builder.setErrorHandler(resolver) document = builder.parse(xmlFileName) except SAXParseException, spe: parseError = 1 </script> <!-- Quit if there is any parsing error --> <if expr="parseError"> <sequence> <script> errmsg = 'Error occurred parsing file %s\n line: %s\n msg: %s' % ( xmlFileName, spe.getLineNumber(), spe.getMessage()) </script> <log>errmsg</log> <message>errmsg</message> <terminate/> </sequence> </if> <return>document</return> </sequence> </function> <script> # These imports only need to be done once per job, no matter # how many xml documents are parsed from java.io import File from java.io import StringReader from org.xml.sax import InputSource from org.xml.sax import SAXParseException from org.xml.sax.helpers import DefaultHandler from javax.xml.parsers import DocumentBuilderFactory from javax.xml.parsers import DocumentBuilder from org.w3c.dom import Document from org.w3c.dom import Element from org.w3c.dom import Node from org.w3c.dom import NodeList # Name of file containing STAX DTD (or whatever DTD you want used) to # when validating/parsing an xml file dtdFileName = 'C:/stax.dtd' # ************************************************************************ # # Following are the private Python classes # # ************************************************************************ # # This class handles XML Parsing exceptions class ParserException(Exception): pass # This class handles the exception raised by XML parser class ParserResolver(DefaultHandler): def resolveEntity (self, publicId, systemId): return InputSource(dtdFileName) def error (self, e): raise 'error', e def warning (self, e): raise 'warning', e def fatalError (self, e): raise 'fatal', e </script> </stax> | |||
2.7. Globalization | |||
2.7.1. | How do I use STAF/STAX in environments where machines running STAF have different locales? | ||
In general, you don't have to do anything special. The requests submitted to STAF and the results received from STAF are all strings. These strings may contain any arbitrary set of characters, including the NULL (i.e., 0) character. When working in an environment with a heterogeneous set of codepages, STAF will translate the request and result strings from and to the necessary codepages. This ensures that the request and result strings are not misinterpreted by the receiver. In general, when using STAF services, there shouldn't be any round trip problems. "Round trip" in this context means when all requests are originating from the same system, even if the requests are sent to, and the data is stored on, a system with a different codepage. However, if you send, for example, a request to log data containing Japanese codepage specific characters to any system and then query the log from a system using a US English codepage, you won't get the "correct" data, as that is not a valid "round trip". Note: All STAF generated strings are composed of only ASCII-7 characters and will safely survive the translation from/to different codepages. CautionIf you use a STAF service that is written in REXX, it can have round trip codepage translation problems. All of STAF services currently provided are written in C++/Java so they do not have this problem. | |||
2.7.2. | How do I specify non-ASCII characters in a STAF request or STAX job? | ||
If you're specifying a STAF request from the command line, then you can just specify the appropriate characters. Example 10. Specifying a French character in a STAF request submitted via the command line
STAF frenchMach PROCESS START COMMAND c:/test/TestA PARMS "-server français"
If you want to specify non-ASCII characters in a STAX job, then you need to specify them in Unicode. Example 11. Specifying a French character in Unicode in a STAX job <process> <location>'frenchMach'</location> <command>'c:/test/TestA'</command> <parms>'-server fran' + u'\u00E7' + 'ais'</parms> </process>
Example 12. Specifying Chinese characters in Unicode in a STAX job <script>dirName = '/tmp/Sun2_' + u'\u4F3A\u670D\u5668'</script> <stafcmd> <location>'chineseMach'</location> <service>'FS'</service> <request>'CREATE DIRECTORY %s' % (dirName)</request> </stafcmd>
If you want to specify non-ASCII characters in a STAF request submitted via a Java program, then you need to specify them in Unicode. Example 13. Specifying Chinese characters in Unicode in a PROCESS START request via a Java program String machine = "chineseMach"; String service = "PROCESS"; String serverName = "\u4F3A\u670D\u5668_HP"; String request = "START COMMAND " + STAFUtil.wrapData("/test/startServer.sh") + " PARMS " + STAFUtil.wrapData(serverName) + " WAIT"; STAFResult submitResult = handle.submit2(machine, service, request);
If you need to specify non-ASCII characters in a request, then you need to be aware of some anomalies if your target system is a Windows system that isn't using an English codepage and whose ANSI codepage (ACP) identifier is different from the OEM codepage (OEMCP) identifier. The system locale determines which codepages are defaults for the Windows system. However, some European locales such as French and German set different values for the ACP and OEMCP. See section "2.7.1 Windows Codepage Translation Anomalies" in the STAF User's Guide for more information on these Windows codepage translation anomalies. | |||
2.7.3. | How do I know what codepage STAF is using on my machine? | ||
To see the codepage that STAF is using, check the value of STAF variable STAF/Config/CodePage. For example:
STAF testmach1 VAR RESOLVE {STAF/Config/CodePage}
| |||
3. Debugging STAF | |||
| |||
3.1. General Questions | |||
| |||
3.1.1. | What should I do if I'm having a problem with STAF or one of its services? | ||
If you are having a problem with STAF or one of its services, follow these steps to resolve the problem:
| |||
3.1.2. | What information should I include when asking questions or reporting bugs? | ||
When you are posting to the Help forum or submitting a new bug, the STAF development team will be better able to quickly resolve your problem if you supply the following information:
| |||
3.1.3. | Explain RC 16 when attempting to send a STAF request to a remote machine | ||
Return code of 16 means "No Path To Machine". This means that STAF could not talk to the target system, with likely causes being:
| |||
3.1.4. | Why can't my STAF machines communicate? | ||
If you are having problems getting two STAF machines to communicate, try the following steps on each machine:
Procedure 2. Changing the DNS settings on Windows 2000
Procedure 3. Changing the DNS settings on Windows XP
The following paragraph only applies to IBM users of STAF/STAX. If you are running a Windows e-business client, and other machines can't ping the e-business client, it is likely that the e-business client is running "Net Firewall", which disables the ability of other machines to ping the e-business client (which also means that STAFProc on other machines will not be able to communicate with the e-business client). To determine if the machine is running Net Firewall, open the Network Connection the machine is using, and click on "Properties". If "Net Firewall" is listed as a component, and it is checked, then the e-business client will experience this problem. If you uncheck "Net Firewall" and click on OK, other machines will be able to ping the e-business client, and STAFProc on other machines will be able to communicate with the e-business client. CautionDO NOT UNINSTALL NET FIREWALL! The AT&T Net Client will not run without Net Firewall, and if Net Firewall is uninstalled, you must completely reinstall the AT&T Net Client. Procedure 4. Changing the DNS settings on Linux
Procedure 5. Changing the DNS settings on HP-UX
Certain versions of Linux set up a high level of security access for incoming requests on specific ports (including STAF requests, which, by default, come in through port 6500). From a Linux machine, if you are able to successfully send a staf ping to another machine, but the other machine cannot do a staf ping to the Linux machine (and you have verified that the DNS information is set up correctly on both machines), try the following (note that this example is for a RedHat 8.0 setup):
| |||
3.1.5. | Why aren't my entries in /etc/hosts being used for STAF communication (particularly on Linux SLES)? | ||
On Linux, if you are using /etc/hosts to specify hostnames/IPs, and a regular "ping" to the hostname works, but a STAF ping fails with RC 16, it is likely that your /etc/hosts file is not being used. Ensure that your /etc/host.conf file looks contains order hosts, bind Also verify that the /etc/nsswitch.conf file contains: hosts: files dns If your /etc/host.conf file contains the following line: multi on You must remove or comment out this line, and then restart STAFProc. | |||
3.1.6. | Why can't I use the HELP service when STAF is not running? | ||
staf local help error error-number doesn't work if STAF is not running on your workstation. Users can access help messages offline (when STAF isn't running) by viewing the STAF documentation. STAF documentation is installed on the local system (if a typical install was done). The "STAF API Return Code Reference" contains a quick reference to the STAF return codes and is available at staf/docs/STAFRC.htm or you can view it on the STAF SourceForge website at http://staf.sourceforge.net/current/STAFRC.htm. | |||
3.1.7. | Why isn't help provided for the ECHO, PING, and DELAY services? | ||
The simple STAF services (Echo, Ping, Delay) all have just one option (the same name as the service) and have never provided a HELP option. The syntax for these services is documented in the STAF User's Guide and the Service Command Reference at http://staf.sourceforge.net/current/STAFCMDS.htm. | |||
3.1.8. | Why are there are more STAF processes on Linux? | ||
If you issue the following command
ps -ef | grep -i staf,
you will see more STAFProc processes (typically 10 or more) on Linux than on other platforms (which there's only one). This is because the Linux base operating system doesn't really have threads. Threads are simulated on Linux using processes, so each thread shows up as a process. | |||
3.1.9. | Why am I having problems (such as an RC 6) submitting a request to a Java service? | ||
If you are having a problem accessing a Java service, such as getting an RC 6 for any request you make to a Java service, the Java service's JVM may have encountered an error or may have been killed. Check the Java service's JVM log to see if any errors were logged. The JVM logs are stored in the {STAF/Config/STAFRoot}/data/JSTAF/<JVMName> directory on the system where the Java service is registered. The current JVM log is named JVMLog.1. If the JVM log contains an OutOfMemory error, any Java services using this JVM will have to be removed and added (registered) in order to start accepting requests. You may want to look at increasing the JVM's maximum heap size as the Java service(s) using this JVM may require more memory than can be allocated. Refer to the STAF User's Guide, section "4.4.3 JSTAF service proxy library", for more information on how to do this. Note that if STAX is the Java service that ran out of memory, make sure that you are running STAX Version 1.5.3 or later which contains a significant memory leak fix. If the JVM was killed, there won't be errors regarding this in the JVM log, but the following error is written to the STAFProc window when a request is made to a Java service whose java executable has died: In JSTAF.STAFServiceAcceptRequest: Caught STAFException Name : STAFConnectionConnectException Location : d:\dev\sf\src\staf\stafif\win32\STAFLocalConnection.cpp(162) Text : OpenProcess2 Error code: 87
If the JVM was killed, any Java services using this JVM will have to be removed and added (registered) in order to start accepting requests. | |||
3.1.10. | Why is STAFProc terminating on some Unix platforms (such as Solaris) when the STAFProc terminal is exited? | ||
For example, if you have a script such as: PATH=/usr/local/staf/bin:/usr/local/java/bin:$PATH export PATH CLASSPATH=/usr/local/staf/lib:/usr/local/staf/lib/JSTAF.jar:$CLASSPATH export CLASSPATH STAFCONVDIR=/usr/local/staf/codepage export STAFCONVDIR LD_LIBRARY_PATH=/usr/local/staf/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH /usr/local/staf/bin/STAFProc &
STAF will start fine if you log in and exec this script, but when you log out, STAF terminates. To resolve this you should change the last line in the script to: nohup /usr/local/staf/bin/STAFProc >/tmp/STAFProc.out 2>&1 &
Make sure you redirect STAFProc's stdout and stderr to a file, as shown above, because STAFProc's output is very important when investigating a STAF problem.
# man nohup
NAME
nohup - run a command immune to hangups
SYNOPSIS
/usr/bin/nohup command [ argument ...]
/usr/xpg4/bin/nohup command [ argument ...]
DESCRIPTION
The nohup utility invokes the named command with argu-
ments supplied. When the command is invoked, nohup arranges
for the SIGHUP signal to be ignored by the process.
The nohup utility can be used when it is known that command
will take a long time to run and the user wants to logout of
the terminal; when a shell exits, the system sends its chil-
dren SIGHUP signals, which by default cause them to be
killed. All stopped, running, and background jobs will
ignore SIGHUP and continue running, f their invocation is
preceded by the nohup command or if the process programmati-
cally has chosen to ignore SIGHUP.
| |||
3.1.11. | Why don't I see any Java service output in the STAFProc console anymore? | ||
The console output was redirected because in STAF 2.4.4 we changed the way JVMs for STAF Java services (such as STAX) output all of their stdout/stderr data (including the output of <script>print...</script> since that is being written to the JVM's stdout). All of the output that was formerly in the console output should now be in the JVMLog file. The file is located at: {STAF/Config/STAFRoot}/data/JSTAF/JVM Name/JVMLog.x where x is a number and JVM Name is STAFJVM1 by default unless you used the JVMName OPTION when configuring the Java service and set it to another name. If you look at your c:/staf/data/JSTAF/STAFJVM1/JVMLog.1 file, you should see something like: ****************************************************************************** *** 20030418-14:40:33 - Start of Log for JVMName: STAFJVM1 *** JVM Executable: java *** JVM Options : none ******************************************************************************
| |||
3.1.12. | When using Sun Java 1.4.2, why are the -Xmx settings for my Java STAF service not being used? | ||
This appears to be a bug in Sun Java 1.4.2 where it is not using the -Xmx heap settings. This means that if you are running Java STAF services with Sun 1.4.2, and specifying the OPTION J2=-Xmx option, the option will not be used and your service JVM will run out of memory at a much lower heap size (the actual limit seems to vary by OS). IBM Java 1.4.2 works correctly (http://www-106.ibm.com/developerworks/java/jdk/index.html) | |||
3.2. STAF Install Questions | |||
| |||
3.2.1. | If the InstallShield installer fails, how do I get debug information? | ||
To generate the STAF ISMP log file, run the ISMP installer with the -is:log option:
STAF-250-setup-linux -is:log /tmp/log.txt
The /tmp/log.txt file (you can name this anything you want) will have details on the installation. | |||
3.2.2. | What if the InstallShield installer fails, or does not complete the installation on Linux? | ||
InstallShield Multiplatform only supports a subset of Linux versions. You can view which Linux versions are supported at InstallShield Multiplatform 5.03 System Requirements. You may be able to install STAF via InstallShield on non-supported Linux platforms, but errors may be reported during the installation, and you will likely need to set the required environment variables manually: export PATH=/usr/local/staf/bin:$PATH export LD_LIBRARY_PATH=/usr/local/staf/lib:$LD_LIBRARY_PATH export CLASSPATH=/usr/local/staf/lib/JSTAF.jar:$CLASSPATH
If the Linux InstallShield Multiplatform STAF installation fails on Linux, you can use the STAF tar.gz installation file as an alternative. Please refer to the STAF User's Guide for more information on using the tar.gz installation file. | |||
3.2.3. | What if the InstallShield installer generates a series of dots, but never completes? | ||
This error can occur on Unix machines when you are telnet'ing into the machine remotely. The STAF InstallShield MultiPlatform installer is a GUI application, therefore, you must export your DISPLAY from the Unix machine to the machine from which you are telnet'ing. Most applications will give you an error message if the DISPLAY is not correctly exported, but, there is a bug in InstallShield MultiPlatform where it does not give you an error message and will just sit there. The solution is to Export your DISPLAY, for example: export DISPLAY=myHostname.austin.ibm.com:0.0
| |||
3.2.4. | What if AIX STAF environment variables (PATH, LIBPATH, etc.) are not set when opening a terminal? | ||
Edit the file ~/.Xdefaults (create it in your home directory if it does not exist) and add the following line: *loginShell:true Save the changes and logout/login. Any terminals that you open will have /etc/profile executed automatically (so that STAF's InstallShield environment variable updates will be read). | |||
3.2.5. | When running STAFInst on Solaris, why does it fail with "test: unknown operator -ef"? | ||
If you receive this error message when running the command ./STAFInst" on Solaris, this indicates that the current Solaris shell does not support certain "test" commands. The solution for this problem is to enter bash at your shell prompt prior to entering ./STAFInst. | |||
3.2.6. | Explain message "JAR Archive failed security check corrupt JAR file" when trying to download a STAF jar file | ||
Certain browsers may report this problem when downloading jar files. To resolve the problem, "shift-click" on the link to download the jar file. | |||
3.2.7. | Why does the STAF InstallShield MultiPlatform install fail on Redhat Linux Enterprise 3.0? | ||
InstallShield MultiPlatform does not currently support Redhat Linux Enterprise 3.0. Here is a link to the list of the supported operating systems: http://www.installshield.com/downloads/imp/imp_readme53.asp So, instead of using our STAF ISMP installer, you need to use the STAF264-linux.tar.gz file. Section 3.4.3 "Installing Using STAFInst" of the STAF User's Guide (http://staf.sourceforge.net/current/STAFUG.htm) has more information. The only manual thing that you will need to do with the tar.gz file is update your /etc/profile file. | |||
3.2.8. | What entries do I need for STAF in my /etc/profile file if I am using the STAF tar.gz installation? | ||
Below is an example of the lines needed in /etc/profile when using the STAF tar.gz installation. You can cut and paste this directly into your /etc/profile if you have installed STAF to the default location (/usr/local/staf): if [ -z "`echo $PATH`" ] then PATH=/usr/local/staf/bin else PATH=`echo $PATH`:/usr/local/staf/bin fi export PATH if [ -z "`echo $LD_LIBRARY_PATH`" ] then LD_LIBRARY_PATH=/usr/local/staf/lib else LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH`:/usr/local/staf/lib fi export LD_LIBRARY_PATH if [ -z "`echo $CLASSPATH`" ] then CLASSPATH=/usr/local/staf/lib/JSTAF.jar:/usr/local/staf/samples/demo/STAFDemo.jar else CLASSPATH=/usr/local/staf/lib/JSTAF.jar:/usr/local/staf/samples/demo/STAFDemo.jar:`echo $CLASSPATH` fi export CLASSPATH STAFCONVDIR=/usr/local/staf/codepage export STAFCONVDIR Note that this example is for Linux. On other Unix platforms, use the appropriate library environment variable (instead of LD_LIBRARY_PATH). | |||
3.3. STAF Startup Questions | |||
| |||
3.3.1. | Explain startup error: 27:Error starting JVM using ..., RC: 10, OSRC: 2 | ||
This error can occur when starting STAFProc if Java STAF services (such as STAX, Event, EventManager, Cron, Email, etc.) are configured in the STAF.cfg file. In order to run Java STAF services, you must have a version of Java (1.3.0 or later) installed on the machine. This error message will be displayed if STAFProc can't find the "java" binary executable. The error message indicates a STAF return code of 10 (which indicates a base OS error), and the OS error code is 2 (which means that the file that the OS attempted to execute could not be found). In this case, the JVM: indicates that "java" was the file that could not be found. The "java" binary executable must either be in the PATH environment variable (so that if you type java -version from a shell prompt, the executable is found and returns the version number), or you can optionally specify the java executable in the STAF.cfg file, such as: SERVICE STAX LIBRARY JSTAF EXECUTE C:/STAF/service/STAX.jar OPTION JVM=/opt/sunjdk1.4.0/jre/bin/java
| |||
3.3.2. | Explain startup error: Error binding server socket, rc = 67 | ||
This error can occur on Unix if STAFProc has not been shutdown correctly. The error will be displayed when you attempt to restart STAFProc. To resolve the problem:
As a last resort, reboot the machine. | |||
3.3.3. | Explain startup error: Error binding server socket, rc = 10048 | ||
This indicates that the socket address is already in use. This error occurs if STAF attempts to bind a socket to an IP address/port that has already been used for an existing socket, or a socket that wasn't closed properly, or one that is still in the process of closing. You should wait approximately 2-3 minutes for TCP/IP to complete the socket close and retry starting STAF. You can also try typing ps or ps -ea and determine if there are any processes that STAF started which are still running. If there are any, type kill xxx where xxx is the PID for the process. NoteSome Solaris systems require a system reboot to fix this condition.
| |||
3.3.4. | Explain startup error: 38:Illegal access to class: com.ibm.staf.service.... | ||
This error occurs if you attempt to register a Java service that has not been declared public in its class definition. Every STAF Java service's class definition should look like: public class CronService implements STAFServiceInterfaceLevel3
| |||
3.3.5. | Why does STAF's user registration fail each time STAFProc is started? | ||
During the STAF installation, if you selected to register STAF, everytime STAF starts it will attempt to register the user information with a machine that is internal to IBM. Once this registration is successful, STAF will no longer try to register. However, the registration will fail for all non-IBM users, and will attempt to register (and fail) each time STAF is started. You can either choose to let it fail forever, or delete the STAFReg.inf file (in the root STAF directory) and STAF will stop trying to register. | |||
3.3.6. | Explain startup error: Error initializing service, RESPOOL. RC: 4008 | ||
The ResPool RC 4008 means "The directory specified by the DIRECTORY parameter when registering the service or the default directory could not be created." It is likely that STAF was installed as another userid, and you are now trying to use the ResPool as a different userid that doesn't have write access to the STAF directory. | |||
3.3.7. | What should I do if STAF fails to init with Windows Terminal Server? | ||
When using Windows 2000 Terminal Server and Windows XP remote desktop feature with multiple users on a machine, only the user starting the STAF process (STAFproc) can execute STAF commands from the command line. Others users on the machine receive 'Error registering with STAF, RC: 21' when issuing STAF commands. To resolve this, install STAF as a Windows Service. See FAQ topic "How do I start STAF as a Windows service". | |||
3.3.8. | On SLES8, why do I get an error starting STAF: STAFProc: /usr/lib/libstdc++.so.5: version `GLIBCPP_3.2.2' not found (required by STAFProc) | ||
This indicates that you do not have the latest libraries on the SLES8 system. You need to install Service Pack 3 (SP3) to upgrade the system libraries. | |||
3.3.9. | Explain startup error on z/OS: Error binding server socket, rc = 1115 | ||
This indicates that the socket address is already in use. This error occurs if STAF attempts to bind a socket to an IP address/port that has already been used for an existing socket, or a socket that wasn't closed properly, or one that is still in the process of closing. You should wait approximately 2-3 minutes for TCP/IP to complete the socket close and retry starting STAF. You can also try typing ps or ps -ea and determine if there are any processes that STAF started which are still running. If there are any, type kill -9 xxx where xxx is the PID for the process. | |||
3.4. PROCESS service Questions | |||
| |||
3.4.1. | Explain RC 10 when attempting to run a process | ||
Return code 10 means "Base OS Error", and the additional info provided in STAFResult is the actual error returned by the operating system. One of the most common reasons for getting a Base OS Error is "File Not Found". On Windows systems, OS error code 2 means "The system cannot find the file specified". On Unix systems, OS error code 2 means "No such file or directory". If you receive an OS error code 2, make sure the executable or script file is in the PATH of the machine where it will be executed., or fully qualify the COMMAND option on the process request (i.e. /opt/tests/mytest). For Windows systems, you can find more information for OS error codes by typing "net helpmsg <error code>" (or by typing net help <error code>" on Windows 95/98/ME). So, to find more information for OS error code 2 on a Windows 2000 system, type:
net helpmsg 2
For Unix systems, you can find more information for OS error codes from include files named errno.h found in directory /usr/include and its subdirectories. | |||
3.4.2. | Explain RC 25 when starting a process on a remote machine | ||
This error indicates that you have submitted a request from a machine which is not authorized to perform the request. To start a process on a remote machine, a TRUST level of 5 is required. To resolve the problem:
| |||
3.4.3. | Explain why I'm having a problem interacting with process queues for processes started via the command line | ||
When you submit a request to STAF from the command line, a unique handle is generated for that request. After the request completes, that handle is no longer active in STAFProc. If you were to submit a subsequent STAF request from the command line which referenced that handle or was dependent upon the continued existence of that handle, your request would fail. Messages are sent to queues associated with specific handles. So, if you register with STAF, and then someone queues you a message, you can retrieve it off your handle's queue. The STAF command line utility works just like any other STAF application. It registers with STAF, performs a request (which is the service request you specify), and then unregisters. That last step causes the handle to be deleted. Every time you run the STAF command line utility it gets a different handle. When the process you started finishes, it tried to send the message to the queue of a handle that no longer existed. If you were to do a queue list, you would be listing the queue of a completely different handle than the one that submitted the "process start" request. If you were doing all of this inside a program, then it would have worked like you anticipated. From the command line, you can simulate it by:
| |||
3.4.4. | Why are child processes not killed on Windows? | ||
If you terminate a STAX job (or send a Process Stop request to a running STAF process) on Windows, any child processes that the process has created will not be terminated. This is a limitation on Windows platforms. To resolve this problem you can specify the option: STOPUSING WM_CLOSE on the PROCESS START request, or specify the <stopusing>'WM_CLOSE'</stopusing> element for a STAX <process> element. | |||
3.4.5. | Why can't a STAF process log its output to an AFS directory? | ||
When attempting to start a Process on a remote machine so that the output can be logged to an AFS directory, STAFProc needs to be started in an authenticated "session" in order to be able to store the log files in AFS-space. | |||
3.4.6. | Why do I get a SIGABRT after a STAF process has completed on HP-UX? | ||
If you see the following error on an HP-UX machine after a STAF process has completed: Received signal 6 (SIGABRT) /usr/lib/dld.sl: Call to __sigenable() failed /usr/lib/dld.sl: Not owner Received signal 6 (SIGABRT) /usr/lib/dld.sl: Unresolved symbol: __h_errno__Fv (code) from /usr/local/staf/l ib/libSTAF.sl Received signal 6 (SIGABRT) /usr/lib/dld.sl: Call to __sigenable() failed /usr/lib/dld.sl: Not owner Received signal 6 (SIGABRT) /usr/lib/dld.sl: Unresolved symbol: __h_errno__Fv (code) from /usr/local/staf/l
This is likely due to an incorrect hostname. Verify that the DNS is setup correctly an all machines (Refer to "Why can't my STAF machines communicate?"). | |||
3.4.7. | Explain error message: "STAFProcessManager::processMonitorThread: Parent could not set child's pgid: 13" | ||
Periodically on Unix systems, you may see this error message. You can ignore these messages (you should not encounter any problems because of the messages). | |||
3.4.8. | Explain Unix error message: STAFProcessManager::processMonitorThread: Could not start process (execve): 8 | ||
If you get this error message when trying to start a process on a Unix system, the 8 in the error message is the errno that is being set by the operating system. For example, an errno of 8 on a Solaris 5.7 system, according to the /usr/include/sys/errno.h file, means "Exec format error". This indicates that there is a problem with the executable you specified in the process start command. If you specified a shell script, check to see if it is missing #! on the first line. Check if you can execute the same command (and parameters, if specified) without involving STAF. | |||
3.5. FS service Questions | |||
3.5.1. | Why does COPY FILE request fail when no TOMACHINE is specified? | ||
From machine m1 this command fails:
C:\>STAF m2 FS COPY FILE c:/staf/data/log/global/temp.log TOFILE c:/staf/data/log/global/archivetemp.log
Error submitting request, RC: 17
Additional info: c:/staf/data/log/global/archivetemp.log
From machine m1 this command works:
C:\>STAF m2 FS COPY FILE c:/staf/data/log/global/temp.log TOFILE c:/staf/data/log/global/archivetemp.log TOMACHINE m2
This is working as expected/designed. The default for the TOMACHINE option is the system that originated the request. So, if m1 does not actually have a c:/staf/data/log/global directory, then STAF will not be able to create the archivetemp.log directory. Once you add TOMACHINE m2, it is obvious you were trying to copy a file "locally" on the remote system, which does require the use of the TOMACHINE option. | |||
3.5.2. | Why are my text files copied via the FS service not converted correctly between Windows and Unix? | ||
Beginning with STAF 2.5.0 and later, you can use a TEXT option on a FS COPY FILE or GET FILE request (or TEXTEXT options on a FS COPY DIRECTORY request) to convert line-endings between Windows and Unix and to convert between codepages if necessary. See the "File System (FS) Service" section of the STAF User's Guide for more information. | |||
4. Debugging STAX | |||
| |||
4.1. General Questions | |||
| |||
4.1.1. | Where can I find more information about Python? | ||
| |||
4.1.2. | Why is STAX still showing a process as running, even though it has completed? | ||
If you are running a STAX Job, and it shows that a process is still running, even though the process has actually completed, this is likely a DNS problem with either the STAX service machine or the machine where the process was executed (where the machine that executed the process is unable to find the STAX service machine in order to deliver the process completion message). Refer to "Why can't my STAF machines communicate?" to resolve this problem. | |||
4.1.3. | Why am I getting RC=10 and STAFResult=8 when starting a Java process in a STAX job? | ||
Certain Unix Java versions will contain a /bin/java file that is actually a soft link to a wrapper shell script file, rather than a binary executable file. If you try to start a Java process in a STAX job: <process> <location>machName</location> <command>'java'</command> <parms>'TestA'</parms> </process> the result will be RC=10 and STAFResult=8. The Operating System return code 8 indicates "Exec format error". To resolve this problem, specify the 'shell' attribute: <process> <location>machName</location> <command mode="'shell'">'java'</command> <parms>'TestA'</parms> </process>
| |||
4.1.4. | Why does my eMail Service's SEND request resulting in RC 7 when quotes or double quotes are in the message? | ||
If the message request has embedded quotes or double quotes, it may cause the STAF command parsing to fail (resulting in the RC 7). Here is a portion of a STAX job that shows how to get this working: <script> from com.ibm.staf import STAFUtil emailmessage = STAFUtil.wrapData(emailmessage) </script> <stafcmd> <location>'local'</location> <service>'email'</service> <request>'send to user@us.ibm.com message %s' %(emailmessage)</request> </stafcmd> <if expr="RC !=0"> <message>'RC: %s result: %s' % (RC, STAFResult)</message> </if>
| |||
4.1.5. | Why am I getting a java.lang.NullPointerException at org.python.core.ThreadState.entrRepr in my JVMLog.1 file? | ||
The following NullPointerException at org.python.core.ThreadState.enterRepr(ThreadState.java) is a known problem in IBM Java's JIT: ****************************************************************************** *** 20030911-12:50:41 - Start of Log for JVMName: STAFJVM1 *** JVM Executable: java *** JVM Options : -Xms128m -Xmx512m ****************************************************************************** java.lang.NullPointerException at org.python.core.ThreadState.enterRepr(ThreadState.java(Compiled Code)) at org.python.core.PyList.toString(PyList.java(Compiled Code)) at org.python.core.PyObject.__repr__(PyObject.java(Compiled Code)) at org.python.core.PyObject.__str__(PyObject.java(Compiled Code)) at com.ibm.staf.service.stax.STAXThread.pyStringEval(STAXThread.java(Compiled Code)) at com.ibm.staf.service.stax.STAXMessageAction.execute(STAXMessageAction.java(Compiled Code)) at com.ibm.staf.service.stax.STAXThread.execute(STAXThread.java(Compiled Code)) at com.ibm.staf.service.stax.STAXThreadQueue$QueueThread.run(STAXThreadQueue.java:66) If you see this NullPointerException in your JVMLog.1 file when debugging a problem running a STAX job, verify that the JVM that STAX is using is IBM's java by doing:
java -version
This problem is in the JIT in IBM Java versions 1.3.x, 1.4.0, and 1.4.1 and has been seen on both Windows and Unix systems. This problem has been reported to IBM Java support and is under investigation. When this NullPointerException occurs in the JVM, any services using this JVM can no longer function until the services using this JVM are removed and re-added via the SERVICE service or STAFProc is shutdown and restarted. There are two workarounds:
| |||
4.1.6. | Why aren't changes to imported Python modules picked up in my STAX job? | ||
Use the built-in Python "reload" function if you want to pick up changes made to imported Python modules without having to unregister and register the STAX service (either by stopping STAF and restarting it or by using the SERVICE service to dynamically delete and add the STAX service). Note that there is a "gotcha" in that reload may not impact "from" imports. Reloading allows you to test Python module changes immediately after reloads, without having to unregister the STAX service. Here's more detailed information about using the built-in Python "reload" function. One of the most common questions Python beginners seem to ask when using modules is: why won't my imports keep working? The first import works fine, but later imports in STAX jobs seem to have no effect. They're not supposed to, and here's why:
Python loads, compiles, and runs code in a module file only on the first import, on purpose; since this is an expensive operation. So, even across STAX jobs, a Python module's code is run only once per STAX service by default. But, sometimes you really want a module's code to be rerun. To force a module's code to be reloaded and rerun, you need to ask Python explicitly to do so, by calling the reload built-in function. Using reload can make your STAX jobs more dynamic. In a nutshell:
Unlike import and from:
Because reload expects an object, a module must have been previously imported successfully before you can reload it. Reloading looks like this: import module # initial import # Use module.attributes ... # now, go change the module file ... reload(module) # get updated exports # Use module.attributes You typically import a module, then change its source code in a text editor and reload. When you call reload, Python rereads the module file's source code and reruns its top-level statements and changes a module object in-place, so every reference to a module object is automatically effected by a reload. Note that there is an important "gotcha" in that reload may not impact fromimports. In fact, the from statement is the source of all sorts of gotchas in Python. Because from copies (assigns) names when run, there's no link back to the module where the names came from. Names imported with from simply become references to objects, which happen to have been referenced by the same names in the importee when the from ran. Because of this behavior, reloading the importee has no effect on clients that use from; the client's names still reference the objects fetched with from, even though names in the original module have been reset. For example: from module import X # X may not reflect any module reloads! ... reload(module) # changes module, not my names X # still references old object The solution to this is: Don't do it that way. To make reloads more effective, use import and name qualification, instead of from. Because qualifications always go back to the module, they will find the new bindings of module names after calling reload: import module # get module, not names ... reload(module) # changes module in-place module.X # get current X; reflects module reloads So, let's say you have a Python file, changer.py, in directory /usr/mypyfuns that contains a function called getValue. For example, say changer.py looks like: value = 'First value' def getValue(): return value Here's an example of a STAX job that tests reloading function getValue from module changer in /usr/mypyfuns. If you run this job, even after editing changer.py so that value is assigned some other value, you'll get the updated value. Example 14. Reloading imported function getValue from module changer in /usr/mypyfuns <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE stax SYSTEM "stax.dtd"> <!-- Test reloading Python modules --> <stax> <defaultcall function="TestReload"/>; <script> myPythonDir = '/usr/mypyfuns' import sys pythonpath = sys.path # Append myPythonDir to sys.path if not already present if myPythonDir not in pythonpath: sys.path.append(myPythonDir) # Import import changer # Force new code to load/run reload(changer) </script> <function name="TestReload"> <message>'changer.getValue()=%s' % changer.getValue()</message> </function> </stax> See Python documentation for more information about module reloads. | |||
4.2. STAX <import> Questions | |||
4.2.1. | Why aren't the global <script> elements in the imported XML file executed when importing a STAX function from that file? | ||
Global <script> elements defined in an XML file containing only functions intended to be imported by the <import> element, are not recognized in the body of the functions. In the imported xml file, only the <script> elements contained within the imported <function> will be executed. Just to give a little history, in the early stages of STAX's life, <function>s were not allowed to take arguments (and the <import> element didn't exist either). Any data that you wanted to "pass into" a function had to be previously set in existing variables. To that end, it was necessary to allow <script> elements at the root of the document so that default values could be fed into the functions. However, once we added argument passing to <function>s, we began encouraging that over global <script>s. Nevertheless, we couldn't remove support for global <script>s, as many groups were already using them. When we implemented the <import> element, we felt it would be cleaner to just import the <function>s in the job, as there was less interaction with the pieces of the importing job. For example, what you already had a variable that was overwritten by a <script> in another file, just because you imported a single utility <function> from it. Even if you were expecting a certain variable to be set from the job, you would have to be very careful to import the functions in the job first, and then set the variables, otherwise your values would overwritten. This same line of argument also applies to importing <signalhandler>s. | |||
4.2.2. | Are there any conflict or efficiency concerns when doing nested file imports in a STAX job? | ||
Question: If I have a situation where file A imports files B and C, and files B and C both import file D is that going to cause any sort of conflict when a call is made to a function in file D? Answer: No. Question: If file A imports file B and file B imports file C, does file C get re-imported every time the function in file B is called? If so is there any potential conflict there, and how much will this impact overall efficiency? Answer: No, functions in file C do not get re-imported every time the function in file B is called. However, we should point out that file C will, in fact, be re-imported every time. Now, none of the functions in it will get imported, but the file will be retrieved and parsed each time you try to import something from it. Depending on how big this file is, and how often you are calling the function which imports it, you might either set a STAF variable (with the job number somewhere in it) that you can retrieve across function calls, or have the importing function use "global" scope and set a STAX variable that indicates the import has already been done. You can see this for yourself if you'd like by looking at STAXResult after each <import> element. In the STAX User's Guide, in the section that describes the <import> element, it says: After executing an import element, STAXResult will be set to a list containing:
Here are some STAX jobs that demonstrate this: Example 15. D:/dev/src/stax/A.xml <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE stax SYSTEM "stax.dtd"> <stax> <defaultcall function="FunctionA"/> <script> machName = 'lucas' </script> <function name="FunctionA"> <sequence> <message>'Running FunctionA'</message> <import machine="machName" file="'D:/dev/src/stax/B.xml'" mode="'error'"/> <message> 'After import B.xml:\n%s\n%s\n%s\n%s\n%s\n%s\n%s' % \ (STAXResult[0], STAXResult[1], STAXResult[2], STAXResult[3], STAXResult[4], STAXResult[5], STAXResult[6]) </message> <call function="'FunctionB'"/> <call function="'FunctionB'"/> <call function="'FunctionB'"/> </sequence> </function> </stax> Example 16. D:/dev/src/stax/B.xml <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE stax SYSTEM "stax.dtd"> <stax> <function name="FunctionB"> <sequence> <message>'Running FunctionB'</message> <import machine="machName" file="'D:/dev/src/stax/C.xml'" mode="'error'"/> <message> 'After import C.xml:\n%s\n%s\n%s\n%s\n%s\n%s\n%s' % \ (STAXResult[0], STAXResult[1], STAXResult[2], STAXResult[3], STAXResult[4], STAXResult[5], STAXResult[6]) </message> </sequence> </function> </stax> Example 17. D:/dev/src/stax/C.xml <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE stax SYSTEM "stax.dtd"> <stax> <function name="FunctionC"> <sequence> <message>'Running FunctionC'</message> </sequence> </function> </stax> Here are the results that were logged. As you can see, the second and third time that FunctionB was called, the STAXResult after importing C.xml in FunctionB shows 'FunctionC' showing up in STAXResult[3] instead of STAXResult[1].
C:\>staf local log query machine lucas logname STAX_Job_11_User
Response
--------
20030319-18:52:10|lucas|189|STAX/Job/11|Info|Running FunctionA
20030319-18:52:11|lucas|189|STAX/Job/11|Info|After import B.xml:
None
['FunctionB']
[]
[]
[]
[]
[]
20030319-18:52:11|lucas|189|STAX/Job/11|Info|Running FunctionB
20030319-18:52:11|lucas|189|STAX/Job/11|Info|After import C.xml:
None
['FunctionC']
[]
[]
[]
[]
[]
20030319-18:52:11|lucas|189|STAX/Job/11|Info|Running FunctionB
20030319-18:52:11|lucas|189|STAX/Job/11|Info|After import C.xml:
None
[]
[]
['FunctionC']
[]
[]
[]
20030319-18:52:11|lucas|189|STAX/Job/11|Info|Running FunctionB
20030319-18:52:11|lucas|189|STAX/Job/11|Info|After import C.xml:
None
[]
[]
['FunctionC']
[]
[]
[]
| |||
4.3. STAX Monitor Questions | |||
| |||
4.3.1. | What does RC 2 mean when starting the STAX Job Monitor? | ||
When starting the STAX Job Monitor, if you get an error message "Error registering Job Monitor. Could not register for Job Events RC = 2", this means that Event service name specified in the STAX Job Monitor Properties was not found on the specified Event machine. In the main STAX Job Monitor window, click on File in the Menu bar, and then select Properties. Make sure that the Event Service Name is the correct Event service name for the specified Event machine. Also make sure that the Event service has been installed and configured on the Event service machine. | |||
4.3.2. | What does RC 16 mean when starting the STAX Job Monitor? | ||
When starting the STAX Job Monitor, if you get an error message "Error registering Job Monitor. Could not register for Job Events RC = 16", this means that Event service machine specified in the STAX Job Monitor Properties was not found. In the main STAX Job Monitor window, click on File in the Menu bar, and then select Properties. Make sure that the Event Service Machine is the correct Event service machine. | |||
4.3.3. | What does RC 2 mean when submitting a new job via the STAX Job Monitor? | ||
When starting a new job through the STAX Job Monitor, if you get an error message "STAX Error. RC:2 Error starting Job Monitor <STAX service name>", this means that STAX service name specified in the STAX Job Monitor Properties was not found on the specified STAX service machine. The "<STAX service name>" in the error message is the STAX service name which would not be found. In the main STAX Job Monitor window, click on File in the Menu bar, and then select Properties. Make sure that the STAX Service Name is the correct STAX service name for the specified STAX service machine. Also make sure that the STAX service has been installed and configured on the STAX service machine. | |||
4.3.4. | What does RC 16 mean when submitting a new job via the STAX Job Monitor? | ||
When starting a new job through the STAX Job Monitor, if you get an error message "STAX Error. RC:16 Error starting Job Monitor", this means that STAX service machine specified in the STAX Job Monitor Properties was not found. In the main STAX Job Monitor window, click on File in the Menu bar, and then select Properties. Make sure that the STAX Service Machine is the correct STAX service machine. | |||
4.3.5. | Why I'm I getting a java.util.zip.ZipException running "java -jar STAXMon.jar"? | ||
To run the command java -jar STAXMon.jar, the STAXMon.jar file must be in the current directory (otherwise you will get the ZipException). If it is not in the current directory, then you need to fully qualify the jar file name: java -jar c:/staf/services/STAXMon.jar | |||
4.3.6. | Why doesn't the STAX Job Monitor window have a close confirmation? | ||
Closing the STAX Job Monitor window should never terminate your job. Doing that just closes that view of the job; the STAX job should still be running. In the main STAX Monitor window (which shows the table of currently running STAX jobs), your job still should be there, and you should be able to right click on it and select "Start Monitoring", and you should see a new STAX Job Monitor window for your STAX job. |