Debugging the JZOS configuration script

JZOS Is a great way of running a Java program on z/OS. The documentation is not clear on how you debug the configuration shell program.

The documentation for the batch launcher and toolkit says:

Java™ Batch Launcher and Toolkit for z/OS® (JZOS) is a set of tools that helps you to develop z/OS Java applications that run in a traditional batch environment, and that access z/OS system services.

Overview

The JZOS Batch Launcher is a native launcher for running Java applications directly as batch jobs or started tasks. Java applications can be fully integrated as job steps to augment existing batch applications.

The JZOS Toolkit is a set of Java classes that give Java applications direct access to traditional z/OS data and key z/OS system services.

The JZOS Batch Launcher and Toolkit includes, but is not limited to, the following facilities and features:

  • Run Java applications on z/OS seamlessly in a MVS™ batch job step or started task.
  • Simple but flexible configuration of the Java execution environment.
  • Access to data sets via JCL DD statements.
  • Java interfaces to many z/OS specific APIs and features including SMF, Catalog Search and Logstreams.
  • Invoke z/OS Access Method Services (IDCAMS).
  • Read and write traditional MVS data sets from Java.
  • Communicate with the MVS system console.
  • Pass condition codes between Java and non-Java job steps.
  • Access z/OS Workload Manager (WLM) services.

The combination of the launcher, data access, added system services, and environmental enhancements make running Java on z/OS as batch jobs easier, particularly for Java application developers. The way that Java batch is managed is now the same as it is for z/OS batch applications written in COBOL, PL/I, or other compiled languages.

Benefits

To me, JZOS is a great way of running JAVA because:

  • You need to know very little about OMVS.
  • It is one address space.
  • Configuring the job to WLM is simple. Configuring for OMVS is harder.
  • It is easy to configure.
  • You do not have OMVS address spaces(BPXAS) popping up and disappearing in seconds.
  • The output can go to the spool, so it is easy to go to the bottom and watch the updates. If you have the output going to a file, you have to edit the file, quit the editor, edit the file etc.
  • The output is all in EBCDIC, so you do not get a mixture of ASCII and EBCDIC in a file.
  • It is easy to specify CEEOPTS – I could not find how to do it for OMVS address spaces.
  • It feels faster – this could be due to run having to run many scripts or command before starting Java.

Configuring JZOS

Example JCL

//S1 EXEC PGM=JVMLDM86,REGION=0M,PARMDD=PARMDD 
//PARMDD  DD *,SYMBOLS=(JCLONLY) 
 /+D  -jar   /u/ibmuser/aaa/tomcat.home/bin/bootstrap.jar 
/* 
//SYSTSPRT  DD SYSOUT=* 
//SYSPRINT  DD SYSOUT=* 
//STDERR    DD SYSOUT=* 
//STDOUT    DD SYSOUT=* 
//STDENV DD * 
. /u/ibmuser/jzos.sh 
/* 
//MAINARGS DD * 
-config /u/ibmuser/aaa/tomcat.base/conf/sserver.xml start 
/*
//CEEOPTS DD * 
RPTSTG(ON) 
*/

PGM=JVMLD86 is in my SYS1.SIEALNKE

Where the parmameters are

  • / delimiter after C run time parameters
  • +D produce debug information
  • -jar use a jar rather than a class
  • /u/ibmuser/aaa/tomcat.home/bin/bootstrap.jar is my jar name,

In the STDENV you can have statements like

//STDENV DD *  
echo "HI HETE" 
export JAVA_HOME=/usr/lpp/java/J8.0 
export PATH=/bin:"${JAVA_HOME}"/bin 
export LIBPATH="$LIBPATH": 
echo LIBPATH 
/*

or invoke a shell script which uses . (dot) – to run a shell file in the current environment

//STDENV DD * 
. /u/ibmuser/jzos.sh 
/*

or combinations of both.

If you have some errors in your definitions, JZOS may not report them.

To debug the script

I changed the job to give loglevel of +D

//PARMDD  DD *,SYMBOLS=(JCLONLY) 
   /+D -jar/u/ibmuser/aaa/tomcat.home/bin/bootstrap.jar 
/* 

or set LOGLVL=’+D’ if using the JCL procedure.

I changed by script to add “set -x”

#!/bin/sh 
set -x 

and changed my job

//STDENV DD * 
exec /bin/sh 1>/tmp/jzos1  2>/tmp/jzos2 
. /u/ibmuser/jzos.sh 
/* 

to add the exec statement. It replaces the current shell with /bin/sh and redirects.

After I ran the job, stdout in /tmp/jzos1 and stderr in /tmp/jzos2 provided the output I needed to resolve the problems.

The job will fail because “exec” provides an exit statement, and I got messages like

JVMJZBL1005I Output from DD:STDENV config shell script:
JVMJZBL1009E Child shell process exited without printing environment; //STDENV should not contain ‘exit’
JVMJZBL2999I JZOS batch launcher elapsed time=0 seconds, cpu time=0.070000 seconds
JVMJZBL1042E JZOS batch launcher failed, return code=101

Once you have the shell script running without error, you can comment out

//STDENV DD * 
# exec /bin/sh 1>/tmp/jzos1  2>/tmp/jzos2 
. /u/ibmuser/jzos.sh 
/*

and JZOS should startup and run your program

One minute – debugging an HTML page

I had an HTML page with javascript and wanted to debug it and see what was going on. It was all pretty easy, but some things took a while to understand. I’ll describe some of the things I did using Chrome browser. Firefox has similar capabilities.

I found JavaScript debugging reference which looks pretty good.

Using the Chrome Debugger Tools, part 3: The Sources Tab is pretty comprehensive.

Getting started

  • Display an html page.
  • To get into developer tools use Ctrl+Shift+I

You get a display like

  1. The web page (squashed up) to a narrow column
  2. Elements – you can see the HTML components. As you move your mouse over the elements in the list, the fields in the web page are highlighted
  3. Sources – you can see the source of the program with the javascript etc. Errors in the file will get flagged on this page
  4. Debug” switch. The icon next to it is the “step over”
  5. Watch” – You can specify which variables you want displayed permanently
  6. “Scope” you can list and display all the variables available to you at that point in the web page
  7. An example of the source

Display and edit the HTML

Clock on the Elements tab (2 in the above picture) to display the source.

You may have your javaScript within the page, or referenced by http://./reply.js. You can see these under the page sub tab, or as a tab in the source (7). You may have to click on the name on the “Page” tab, to get it displayed in the source pane.

This shows sssserver.html is the main one, and checkCipher.js has been included. Some of these may be displayed as tabs above the sourc

  • It gives a good high level view of the program for example it may have <head>…</head>. The … show there is omitted content. Click on the … to display the content.
  • As you move your mouse over the HTML the web page elements will be highlighted. Moving over the <body> shows the whole web page, moving over a <p> shows just the paragraph.
  • As you click on some html, it displays the CSS on the right had side.
    • It tells you what CSS is being used for example the “p” tag with option “display”:block
    • As you move your mouse over the CSS picture it highlights the data on the html page
  • You can edit the HTML, add elements, delete elements etc

Set breakpoint

  • Click on the Sources (3) tab
  • Click on the line number of interest – it toggles blue.
  • Run the page

Step through the code

  • Click on the Sources (3) tab.
  • Click on the pause button (4); it gets grayed out
  • Run your script. I clicked the submit button.
  • The display changes and it shows “Debugger paused”.
    • Open the “watch” twistie and click “+”. You can now enter a variable name to display the object.
      • Open the object’s twistie to display the attributes of the object
      • Open the “Scope” twistie. Open the “Local” twistie. This will display all of the local variables. Open the variable’s twistie to see all its attributes. I do not think you can change the data. Use ctrl+alt+left mouse to expand or compress the twistie.
  • Open the “Breakpoint” twistie and select “Pause on uncaught exception” and “Pause on caught exception“. This will stop when it detects a problem
  • If you click the icon next to the Pause Icon (or F10) it will step through the code.
  • If you click on a line of javascript and use right-click you select “Continue to here”.
  • Within an active code segment, hovering over a variable will display the attributes. (You can also go to “Scope” and display from that window. Clicking on the window object( for example) gives all the operations you can do on that object (for example all of the on…. method names) .
  • If your code has console.log(“something”) this will appear in the console tab.

To get out of the current debug press the browser’s stop (X) and browser’s “reload/refresh” button.

Where did it spend its time?

If you click on the “Network” tab it shows where time was spent on the network. For example which files were got, and how long it took to get the data. It gives information on

  • Which file was loaded.
  • Status – 200 is OK.
  • Type eg .gif.
  • Initiator – which page did the request come from.
  • Size ( if it was downloaded) or “cache” if it was already in the browser cache.
  • Time in milliseconds.
  • “Waterfall” breaks down the time spent

Under the “Performance” tab you can record the activity, and display it.

Use Control+E to start, then Ctrl+E to stop it.

It displays information like

What do all of the keys do?

If you click on the settings wheel, and select Shortcuts, it displays all the options and key combinations.

Debugging a java script file?

Chrome caches these. Disable this by going to the Network table and click on “disable cache”