Download ZJAV1

Document related concepts
no text concepts found
Transcript
IBM System z Wildfire Seminars
z/OS Java Exploiters and Java Batch (ZJAV1)
Lee-Win Tai
[email protected]
Louis Wilen
[email protected]
© 2012 IBM Corporation
Administration
Start and Stop times each day
Breaks and lunch
Restrooms
Cell phones and pagers
Fire alarms
What do you do?
• Java developer?
• System administrator?
• DB2, CICS, etc?
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
2
1
Class Schedule
Day 1
•
Welcome & Logistics
•
Unit 1: z/OS Java Overview
Lab 1: System Introduction
•
Unit 2: z/OS Java Exploiters
Lab 2: No lab – take a short break
•
Unit 3: Java Batch
Lab 3: JZOS
•
Unit 4: WebSphere Batch
Lab 4b: WebSphere Batch Installation
Lab 4c: WebSphere Batch Programming
Day 2
•
Unit 5: Shared Class Cache
Lab 5: Shared Class Cache
•
Unit 6: Introduction to Rational Developer for System z
Lab 6: No lab
•
Unit 7: Java and CICS
Lab 7a: CICS Java transactions using pooled JVMs
Lab 7b: CICS Java transactions using JVMservers and OSGi
•
Unit 8: Java and DB2
Lab 8: DB2 Stored Procedures
•
Unit 9: Profiling and Problem Isolation
Lab 9: IBM Support Assistant (optional)
•
Evaluations and departure
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
3
Notice to Government Employees and Representatives
IBM Training and Education
IBM conducts marketing presentations, executive briefings, product exhibitions and demonstrations,
seminars and other sessions to familiarize clients and potential clients with IBM solutions to
information processing problems. In accordance with established IBM practices, these sessions are
provided at no charge.
Some government agencies permit acceptance of this training by employees; other agencies may not.
You should ascertain whether your agency's standards of conduct regulations permit you to attend
this IBM-sponsored education or training session, as it is not IBM's intent or desire that you, your
organization, or IBM violate any statutes or regulations.
Under IBM's established business practices, the fair market value for non-billable IBM education or
training session is zero, as it is normally provided to commercial clients, government clients and
potential clients on a no-charge basis.
The offer of IBM training or education made in conjunction with this notice is void where prohibited by
U.S. Federal, state or local government statute or regulation.
Notice to Government Employees and Representatives
Food and Refreshments
At this IBM function, IBM is providing food and refreshments and considers this a normal business
courtesy. Some U.S. Federal, state or local government agencies do not permit their employees to
accept food or refreshments from contractors doing business with them.
If your agency requires, or if you desire, you may pay the fair market value for the food and
refreshments you consume.
A receipt will be provided upon request.
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
4
2
Softcopy of Class Materials
PRS3583 at http://www.ibm.com/support/techdocs/
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
5
IBM System z Wildfire Seminars
z/OS Java Exploiters and Java Batch
Unit 1: z/OS Java Overview
Last updated: 2012-04-19
© 2012 IBM Corporation
3
Key Concepts of Java
To set the stage and provide a warm-up to details that follow
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
7
Key Concept Behind Java
To provide a platform-independent environment where applications can be
“written once and run anywhere” …
Application
Application
Java Virtual Machine
(JVM)
System x
Application
Application
Java Virtual Machine
(JVM)
Java Virtual Machine
(JVM)
System p5
System z
Java Virtual Machine
(JVM)
System i
That vision is a reality. Provided the levels of the Java are same across all
platforms, and good programming practices are kept, this works.
The key is the isolation of program from hardware …
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
8
4
An Almost Too-Simple Example – Just to Show Concepts
The ubiquitous “HelloWorld” example …
class HelloWorld {
public static void main(String[] args) {
System.out.println(“Hello World!”);
}
}
HelloWorld.java
Java
Compiler
HelloWorld.class
“Bytecode”
Bytecode does not contain processor specific code
Bytecode is the machine language of the JVM
Bytecode is the same no matter what platform you are running on
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
9
Some Key JVM Concepts and Acronyms
A few to get us started …
JVM Heap
The memory allocated within the JVM to support the programs being run. You can generally set the
minimum and maximum values. The heap expands and contracts within those two limits based on what
the applications are doing.
The JVM heap consumes system memory – real or auxiliary.
Garbage Collection, or “GC”
A function of the JVM that determines if objects in the heap are no longer being used. If so, it deletes
the object from the heap and compacts the memory. This is how heaps can contract.
Managing GC is a key element of fine tuning performance. Excessive GC can hinder performance. Too
infrequent could mean excessive memory usage and a very long GC cycle when it does occur.
Garbage collection policies:
http://www.ibm.com/developerworks/java/library/j-ibmjava2/
JIT
“Just In Time” compiler. Translates bytecode into native machine code and caches them.
JVM maintains call count; JIT compilation occurs once threshold reached; call count still maintained
Used to improve performance.
Use –Xnojit to turn off JIT compilation
Use –Xjit:count=<n> to adjust JIT threshold (in Java 6)
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
10
5
Some Acronyms
You’ll hear a lot of terms flying around when discussing Java. We start the
terminology discussion with three key terms:
SDK – Software Developer Kit
Compilers, debuggers and other tools.
JRE – Java Runtime Environment
The Java components necessary to provide
a Java environment. Includes the base
libraries and utilities.
Java for z/OS is
supplied from IBM
as an SDK
SDK 5
SDK 6.0.0
SDK 6.0.1
SDK 7
JVM – Java Virtual Machine
Where the Java programs execute.
Sometimes you’ll see limited implementations providing only
the JRE – just enough to run Java but not the full stuff to
develop/debug. But not on z/OS. z/OS Java is SDK.
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
11
Java on z/OS
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
12
6
Java Runs on z/OS
Java is perfectly compatible with the z/OS platform
http://www-03.ibm.com/systems/z/os/zos/tools/java/products/allproducts.html
SDK 5
31-bit
64-bit
“full function that have passed the
Java compatible test suites”
SDK 6.0.0
31-bit
64-bit
SDK 6.0.1
31-bit
64-bit
SMP/E and non-SMP/E format
SDK 7
31-bit
64-bit
“There is no charge for any of these products.”
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
13
IBM Improvements Over Time
Vendors are allowed to extend the Java base, provided it remains Java
compatible. IBM has provided considerable value-add:
Garbage Collection – various modes (optthruput, gencon, etc.)
Java Record I/O (JRIO)
ASCII Conversion - EBCDIC “only” outside JVM
Java for z/OS SAF Interfaces (RACF, etc.)
JZOS support
zAAP support
New in SDK 6.0.1!
JZOS 2.4.0 enhancements (previously available only from alphaworks):
Enhance Zlogstream class to support IXGBRWSE (read), IXGDELT (delete) and InputStream/OutputStream
Java wrappers
New package (com.ibm.jzos.wlm) with selected z/OS WLM APIs
Support Extended Address Volumes (EAV)
Enable submission of jobs to the MVS internal reader
z/OS Java unique security functions
Support for AES Secure Keys in the IBMJCECCA hardware crypto provider (req. z/OS 1.11 & ICSF HCR7751)
Enhanced ICSF exception handling is added in the IBMJCECCA hardware crypto provider
Exploitation of z196 instructions
Deprecation of JRIO
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
14
7
IBM Java SDK 7
InfoCenter: http://publib.boulder.ibm.com/infocenter/java7sdk/v7r0/index.jsp
Annoucement Letter:
http://www-01.ibm.com/common/ssi/cgi-bin/ssialias?subtype=ca&infotype=an&supplier=897&letternum=ENUS211-265
New in SDK 7
Project Coin language enhancements
Strings in switch – switch (String) { case (“a”): ... }
Multi-catch – catch (ExceptionA | ExceptionB | ExceptionC e) { … }
Try-with-resources / Automatic Resource Management – auto-closeable resources
Underscores in numeric literals – int a = 1_000_000;
http://openjdk.java.net/projects/coin/
More detailed and efficient format for verbose GC
Improved shared class cache support
Last SDK to support JRIO
Migration:
http://www-03.ibm.com/systems/z/os/zos/tools/java/products/jzos/sdk601_jrio2jzos_mig.html
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
15
Choosing Between Java Flavors
31-bit vs. 64-bit SDK 6.0.1
64-bit SDK is not a replacement for 31-bit
• Both have the same SDK 6 APIs
• Can be installed and run simultaneously
Main reasons to stay at 31-bit
• Your applications are not storage constrained by 31-bit addressing
• Your ISV or other middleware vendor requires 31-bit product
Main reasons to go to 64-bit
• Your applications are storage constrained by 31-bit addressing
• Your ISV or other middleware vendor requires 64-bit product
Customers generally don’t go to 64-bit for performance benefits
Under certain scenarios, 64-bit JVM may perform as well or better than 31-bit JVM
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
16
8
What It Looks Like When Installed on z/OS
It’s just a directory structure in the HFS. There are no module libraries or
MVS data sets … everything under common mount:
/shared/java/J6.0.1
/bin
Launch JVM
java
javac
copyright
Compile
/demo
/docs
HelloWorld.class
/include
JDK_INSTALL_OK
/lib
/mvstools
src.zip
/standard
/properties
Key Points:
Possible and quite common to have
multiple versions of Java installed on
the same system
Under separate mount points
Some IBM products come with IBM
Java as part of its install (WebSphere
for z/OS), others rely on separately
installed IBM Java
And you simply point to location where Java is found
A look at the zAAP processor …
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
17
Brief Overview and Background on zAAP
System z Application Assist Processor (zAAP)
Problem Seeking Solution
Java-based applications typically require more CPU resources over
traditional applications
Flexibility and portability of Java comes at a cost
Valuable processors being overwhelmed with Java work
Introducing … the zAAP
zSeries Application Assist Processor
Special use processor that executes Java instructions only
Dispatching of work to zAAP done at low level; well below applications
No changes to Java needed – completely transparent to Java apps
No Impact on MSU Rating of Machine
zAAP cost fraction of general purpose processor cost
Dispatching controlled by IEAOPTxx parmlib – CPs can help if req’d
Offload Java from GP resulting in fewer GP processors required.
Lowers the cost model of running Java on the z/OS platform.
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
18
9
zAAP Requirements
Available on z990, z890 System z9 and follow-on models only
Prerequisites:
• z/OS 1.6 (or z/OS.e 1.6) or higher
• IBM SDK for z/OS, Java 2 Technology Edition, V1.4 with PTF for APAR PQ86689 or higher
• Processor Resource/Systems Manager™ (PR/SM) must be enabled.
Subsystems and Apps using SDK 1.4 or above will exploit zAAPs automatically:
•
•
•
•
•
•
WebSphere for z/OS
CICS®
DB2
IMS™
JAVA Batch
USS
Subsystems don’t really know about zAAPs. IBM Java is what
recognizes and uses zAAP. IBM SDK is what dispatches work
to zAAPs, not the higher-level subsystem
There are restrictions on how zAAPs can be configured
• Must have at least one general purpose processor on LPAR (can’t IPL from zAAP)
• Number of zAAPs can’t exceed number of permanently purchased GP’s on a given machine
model.
If you meet these requirements, you should begin considering zAAP
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
19
zAAP on zIIP
Available on System z9, System z10 and all IBM zEnterprise™
Prerequisites:
– z/OS 1.9 and z/OS 1.10 (with PTFs)
– z/OS 1.11
Eligible workloads
– DB2 for z/OS v8, DB2 9, DB2 X
– z/OS Communications Server
– z/OS XML System Services
– zAAP on zIIP
Ideal for customers without enough zAAP or zIIP-eligible workload to justify a
specialty engine
– Combined eligible workloads may make zIIP cost effective
No special price, code, or software charge needed to get zAAP on zIIP
Planning Considerations for zAAP on zIIP
WP101642 at http://www.ibm.com/support/techdocs
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
20
10
Summary
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
21
IBM ATS Techdocs Website
http://www.ibm.com/support/techdocs
PRS1076
Introduction to zSeries zAAP Presentation
PRS2840
System zSeries zAAP Sizing Analysis
TD102183
New SMF Support for zAAPs and SMF Accounting
PRS689
zPCR
WP100417
z/OS Performance: Capacity Planning Considerations for zAAP Processors
WP101642
Planning Considerations for Running zAAP Work on zIIPs
PRS1224
Implementing zAAPs in the CICS Environment
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
22
11
IBM System z Wildfire Seminars
z/OS Java Exploiters and Java Batch
Lab Exercise 1: System Introduction
WSC Wildfire Class
© 2012 IBM Corporation
VMWare
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
24
12
3270 Emulator
WG31 – 32x80
WG31-WIDE – 55x132
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
25
IBM Americas -- Advanced Technical Skills
26
Userid on Desktop
ZEAM01
© 2012 IBM Corporation
13
Lab: Crash Course in USS and PCOM
Starting the z/OS shell:
1. /etc/profile
2. $HOME/.profile
PCOM
– Use right CTRL key as enter
– Use left CTRL as reset
– Use PF7/PF8 to scroll up/down
– Use PF12 to recall commands
– Use Pause to clear the screen (used mainly in CICS)
OMVS vs ISHELL (ish) vs Direct Login
– UNIX is case sensitive
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
27
14
IBM System z Wildfire Seminars – ZJAV1 – Java Exploiters
LAB 1: SYSTEM INTRODUCTION
Last Updated: 2012-05-08
LAB: SYSTEM INTRODUCTION
The objective of this lab is to provide a basic understanding our lab system, particularly in the areas of Unix
System Services and Java.
Approximate time for completion:
The typical time for completion is 10 to 20 minutes, but varies depending upon the student’s level of familiarity
with Unix System Services and Java.
LAB PREREQUISITES
IBM System z; Java 5 or later
Access to the Unix Systems Services shell command line from either TSO. Optionally, a direct telnet session into
USS may be used for parts of the lab.
LAB OVERVIEW
In this lab, you will become familiar with IBM web sites that contain Java for z/OS information and other
relevant technical data. You will then log on to our z/OS system and compile and execute a Java program under
the OMVS shell. Finally, you will try out the ISHELL, which is a function that profiles an ISPF-like interface to the
Unix file system.
z/OS Java Exploiters and Java Batch
Lab 1: System Introduction
Last Updated: 2012-05-08
Page 2 of 7
©2012 IBM Corporation
LAB STEPS
Note:
When logging on to TSO, specify IKJACCNT in the Procedure field.
□ 01. Information about the zAAP and Java on z/OS is available in several IBM Techdocs. Access the
Techdocs web site at following URL, then search on zAAP to obtain a list of Techdocs that pertain
to the zAAP. You do not need to download any Techdocs at this time; we just want to make you
aware of the location and availability of Techdocs.
http://www.ibm.com/support/techdocs
□ 02. The most current release of Java for z/OS is always available from an IBM web site. .Access the
following URL to view the Java for z/OS product distribution page:
http://www.ibm.com/systems/z/os/zos/tools/java
□ 03. What is the date of the most current release of the 31-bit version of Java 5 for z/OS?
____________________________________
□ 04. What is the date of the most current release of the 31-bit version of Java 6 for z/OS?
____________________________________
□ 05. What is the date of the most current release of the 31-bit version of Java 7 for z/OS?
____________________________________
□ 06. Start a connection to the WG31 system (if not already started) by clicking on the WG31 icon on
the desktop. The application selection screen should appear.
□ 07. Start a TSO session by entering TSO ZEAM01. Complete the logon process process by entering
your password.
z/OS Java Exploiters and Java Batch
Lab 1: System Introduction
Last Updated: 2012-05-08
Page 3 of 7
©2012 IBM Corporation
Note:
If you prefer, you may use a direct USS session by running a telnet client, such as putty.
However, you must use the vi editor, so we recommend this only for experienced Unix
users.
Our system listens for telnet connections on port 1023.
□ 08. The ISPF menu should appear. If the ISPF menu is not displayed after logging on, then start ISPF
by entering ISPF at a TSO command line.
□ 09. Select ISPF option 6 to get to a TSO command line from within ISPF.
□ 10. Enter the OMVS shell by entering OMVS at the TSO command line.
□ 11. The lab system has two levels of Java installed: Java 5 (31-bit and 64-bit) and Java 6 (31-bit and
64-bit). Verify that you are set up to use Java 7 (31-bit) for this lab by examining your .profile
file.
Note:
The first character of .profile is a period.
Edit your .profile file by issuing the following command:
> oedit .profile
Verify that the only JAVA_HOME statement that is uncommented is the one that points to Java
7 (31-bit). You should see lines similar to the following:
#export JAVA_HOME=/usr/lpp/java/J5.0
#export JAVA_HOME=/usr/lpp/java/J5.0_64
#export JAVA_HOME=/usr/lpp/java/J6.0.1
#export JAVA_HOME=/usr/lpp/java/J6.0.1_64
export JAVA_HOME=/usr/lpp/java/J7.0
#export JAVA_HOME=/usr/lpp/java/J7.0_64
Exit from oedit by issuing exit.
□ 12. To cause the changes that you made in step 11 to go into effect, you must exit from the OMVS
shell and reenter the OMVS shell.
Why?
Any changes made to your .profile do not dynamically take effect. Your .profile is read
and executed when you log into the OMVS shell.
z/OS Java Exploiters and Java Batch
Lab 1: System Introduction
Last Updated: 2012-05-08
Page 4 of 7
©2012 IBM Corporation
□ 13. Exit from omvs by issuing exit.
□ 14. Enter the OMVS shell by entering omvs at the TSO command line.
□ 15. Verify that Java 7 is accessible by entering the following at an OMVS shell command line:
> java -version
A response similar to the following should be displayed:
java version "1.7.0"
Java(TM) SE Runtime Environment (build pmz3170-20110827_01)
IBM J9 VM (build 2.6, JRE 1.7.0 z/OS s390-31 20110810_88604 (JIT enabled, AOT enabled)
J9VM - R26_Java726_GA_20110810_1208_B88592
JIT - r11_20110810_20466
GC
- R26_Java726_GA_20110810_1208_B88592
J9CL - 20110810_88604)
JCL - 20110809_01 based on Oracle 7b147
□ 16. We have provided a small Java main program called DisplayProp that displays all of the Java
system properties. Its main purpose in this lab exercise is to demonstrate how to compile and
execute a Java program on a z/OS system. The program is listed below.
import java.util.*;
import java.io.*;
class DisplayProp {
public static void main(String argv[]) {
Properties props = System.getProperties();
for (Enumeration enum1 = props.propertyNames();enum1.hasMoreElements();) {
String key = (String)enum1.nextElement();
System.out.println(key + " = " + (String)(props.get(key)));
}
}
}
□ 17. Change your current directory to /u/zeam01/classes.
> cd /u/zeam01/classes
z/OS Java Exploiters and Java Batch
Lab 1: System Introduction
Last Updated: 2012-05-08
Page 5 of 7
©2012 IBM Corporation
□ 18. Compile the DisplayProp.java program by issuing the following command from the Unix
command line:
> javac DisplayProp.java
□ 19. Execute the DisplayProp.java by issuing the following command.
> java DisplayProp
The DisplayProp program will run and should generate several dozen lines of output that list
the Java system properties.
□ 20. Look at the bottom of your 3270 emulator screen to see the purpose of each function key.
Notice that you can scroll backward and forward in your OMVS session by using the function
keys. Also notice that you can use PF12 to recall previous commands.
□ 21. Based on the output that is displayed to the screen, what is the value of file.encoding?
________________________________
□ 22. What is the value of os.name?
________________________________
□ 23. What is the value of os.version?
________________________________
□ 24. If you want to interrupt and terminate a program, you can send it a logical “CTRL-c”. Since there
is no “CTRL-c” key defined in the 3270 workstation interface, OMVS supports the logical
equivalent by entering ^c, followed by the 3270 Enter key.
Note:
In PCOM, to send CTRL-c, do the following:



shift+6
“c” (just the letter)
right CTRL
z/OS Java Exploiters and Java Batch
Lab 1: System Introduction
Last Updated: 2012-05-08
Page 6 of 7
©2012 IBM Corporation
It is normal behavior for a cent sign (¢) to appear instead of a circumflex.
□ 25. Exit out of the OMVS shell by entering exit at the shell command prompt.
□ 26. Another way of accessing Unix system services is by using the ISHELL. Start the ISHELL by going to
a TSO prompt (ISPF option =6), then entering the ISH command.
□ 27. Enter /etc/ into the panel, then press the Enter key. A list of files in the /etc directory should be
displayed.
□ 28. Enter the letter “b” next to the file named profile to browse the profile file.
□ 29. The /etc/profile file is a shell script that automatically runs whenever any user runs the OMVS
shell. Browse the /etc/profile file to get an idea of some of the things that it does.
Note that the /etc/profile is different from the .profile file in your home directory that you
modified (or at least looked at) in step 11. When you run the OMVS shell, the /etc/profile file
is executed first, followed by the .profile file. Hence, any settings in the .profile file supplement
or override settings in the /etc/profile file.
□ 30. Who might typically manage the /etc/profile file on a production system? Circle one of the
following.
End Users
Systems Programmer
Java programmers
□ 31. Exit from the browse function and from ISHELL by pressing PF3 several times.
□ 32. You have completed this lab exercise.
z/OS Java Exploiters and Java Batch
Lab 1: System Introduction
Last Updated: 2012-05-08
Page 7 of 7
©2012 IBM Corporation
IBM System z Wildfire Seminars
z/OS Java Exploiters and Java Batch
Unit 2: z/OS Java Exploiters Overview
Last updated: 2012-11-27
© 2012 IBM Corporation
What Can Use Java?
Anything that’s capable of “instantiating a JVM”
You
From Telnet or OMVS, issuing java command
Java Batch JCL
Using BPXBATCH or JZOS
Other Programs
If program has access to installed SDK, it can launch JVM
More Traditional Systems
WebSphere Application Server
CICS
DB2 Stored Procedures and User Defined Functions (UDF)
WebSphere Message Broker
IMS
Many different things … they all instantiate a JVM
But in different ways
Different types of Java programs …
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
2
1
Different Types of Java Programs
Servlet and JSP
Java program that runs in a “web container” – typically accessed by users with browsers
JSP – Java Server Page – for dynamic page content. Closely related to servlet.
Run these in WebSphere Application Server, or open source like Tomcat
Enterprise Java Bean (EJB)
More complex standardized structure
Defined in the Java EE standard
Run these in WebSphere Application Server (a Java EE server) and CICS (limited JEE)
Three basic forms:
1. Session Beans
Many WebSphere applications written using Session Beans
2. Entity Beans
Used to represent persistent data. Not quite as common as session beans.
3. Asynch Beans
Behave asynchronously; that is, operations that do not require an immediate response
Message Driven Beans (MDBs) are superset of Asynch beans
Standalone Application or Function
Sometimes known as “Plain Old Java Object” (POJO)
Java, but not written to conform to specifications of the other types listed here
This is what is typically invoked from Java Batch
DB2 stored procedures and UDFs take this form
Programs that uses JCICS classes (in CICS) take this form
The kind you have dictates the JVM you use to run it
© 2012 IBM Corporation
3
IBM Americas -- Advanced Technical Skills
How and Where to Develop Java Applications
Two basic ways:
With a text editor
Only for the most simple
functions. More complex
things will require an IDE
Exception: many IDE’s have text editors to
modify generated code
Integrated Development Environment (IDE) – “Tooling”
Graphical Interface
Pulldowns, generation wizards
Hides the mundane coding work
IBM tools now built on “Eclipse” foundation
A “framework” on which different tools are built. This is what
provides the consistent “look and feel” across different tools.
Eclipse is now open source: http://www.eclipse.org
RAD, RDz, IID, etc.
Quick look at IBM Eclipse-based suite …
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
4
2
How Different IBM Eclipse-based Tools Relate
The different IBM tools all operate on the Eclipse foundation. They provide
different things. You acquire what you need …
Web development (servlets, JSPs)
Web services development
XML and DB access tools
J2EE/EJB & Portal Development
Component Testing
Code Review & Runtime Analysis
z/OS Application Development
XML Services
BMS Map Editor
COBOL and PL/I DB2 Stored Procedures
EGL COBOL Generation
BPEL based processes
Rational
Application
Developer
Rational Web
Developer
WebSphere Broker development
Rational
Developer for
System z
IBM
Integration
Designer
WebSphere
Message
Broker Toolkit
Eclipse
All within a consistent look-and-feel framework
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
5
Java Batch
A Brief Overview
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
6
3
Java Batch Overview
When we say “Java Batch” we mean JVM invoked directly … not JVM as part
of larger subsystem like you have in WebSphere or CICS.
HelloWorld.java
Compilation
javac HelloWorld
HelloWorld.class
Compiled “Bytecode”
(the *.class file)
You could run that from command line:
java HelloWorld
Or you could package that invocation into JCL batch …
© 2012 IBM Corporation
BPXBATCH…
7
IBM Americas -- Advanced Technical Skills
BPXBATCH in JCL
BPXBATCH is a way to issue UNIX System Services commands from a batch
environment. You could invoke the shell and issue java command:
//BPXBATCH JOB (999,XXX),’JAVA BPXBATCH’,CLASS=A,MSGLEVEL=(1,1)
// MSGCLASS=X,REGION=0M,NOTIFY=&SYSUID
//********************************************************************
//* Run Java under a UNIX System Service shell
//********************************************************************
//STEP2 EXEC PGM=BPXBATCH,
// PARM=’SH java HelloWorld’
//STDIN DD DUMMY
//STDOUT DD PATH=’/tmp/&SYSUID..bpxbatch.out’,
Output cannot be routed directly to MVS datasets,
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
another step is required to copy output from HFS files
// PATHMODE=SIRWXU
to SYSOUT
//STDERR DD PATH=’/tmp/&SYSUID..bpxbatch.err’,
Writing
STDOUT
and
The java command and JVM are run in a separate
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
STDERR to temp file
// PATHMODE=SIRWXU
address space
//STDENV DD *
Don't have access to DDs in the JCL from Java
CLASSPATH=/u/myuid/classes
program
//*********************************************************************
Accounting
data doesn't attribute to the batch job
//* Copy HFS output files to SYSOUT, since BPXBATCH can only
write
address space
//* STDOUT and STDERR to HFS files.
//*********************************************************************
Separate Workload Manager (WLM) policy
//STEP3 EXEC PGM=IKJEFT01,DYNAMNBR=300,COND=EVEN
Output will be encoded using default file encoding
//SYSTSPRT DD SYSOUT=*
Can't pass condition code from Java program to
//HFSOUT DD PATH=’/tmp/&SYSUID..bpxbatch.out’
subsequent steps
//HFSERR DD PATH=’/tmp/&SYSUID..bpxbatcherr’
Configuration of Java VM and environment variables is
//STDOUTL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=133,BLKSIZE=137)
//STDERRL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=133,BLKSIZE=137)
inflexible
//SYSPRINT DD SYSOUT=*
//SYSTSIN DD *
OCOPY INDD(HFSOUT) OUTDD(STDOUTL)
Copying temp
OCOPY INDD(HFSERR) OUTDD(STDERRL)
files to SYSOUT
//
It works, but has limitations:
JZOS …
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
8
4
JZOS in JCL
JZOS is an MVS utility written by Dovetailed Technologies, LLC and acquired
by IBM. It’s a custom JVM launcher that overcomes limitations of BPXBATCH
Two smart people wrote MVS program to launch JVM in a better way than BPXBATCH. IBM bought program.
//JZOSBAT JOB (999,XXX),’JAVA JZOS’,CLASS=A,MSGLEVEL=(1,1)
// MSGCLASS=X,REGION=0M,NOTIFY=&SYSUID
//JAVA EXEC PROC=JVMPRC60,
JAVACLS=‘HelloWorld'
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDENV DD *
/etc/profile
:
//
This batch model is generally used for
standalone Java applications … that is,
not servlets, not JSPs and not EJBs
It’s very good at what it does, but if your
programming needs call for a more
interactive application, then something
more is called for.
© 2012 IBM Corporation
9
IBM Americas -- Advanced Technical Skills
Apache and Tomcat
Both are open source projects at the Apache Software Foundation.
www.apache.org
An HTTP server. It runs on a lot of different
hardware platforms, including z/OS
More on the z/OS port coming up
A servlet and JSP container. Java
applications written to the servlet or JSP
specification may execute inside of this
Servlets and JSPs may also execute inside of
WebSphere Application Server. They can’t execute
out of simple JVM invoked by BPXBATCH or JZOS
Key Points:
Browser
Apache
HTTP
Server
Good solution when need is for
relatively simple servlets or JSPs
Tomcat Servlet Engine
Servlet or
JSP
IBM SDK z/OS
Data
WebSphere Application Server can run
servlets/JSPs, but it may be more solution
than you need.
This can run on z/OS
This can use IBM SDK
This can exploit zAAP
T:Z – Quickstart for Tomcat
http://www.dovetail.com/products/tomcat.html
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
Apache on z/OS …
10
5
IBM HTTP Server for z/OS Powered by Apache
In 2006 IBM “ported”* the Apache open source code to z/OS … updating it
with the ability to exploit key z/OS services:
Delivered in WebSphere for z/OS V6.1.0.4 maintenance
SAF-related
SAF aware, including SAF userids and groups, passwords,
keyrings and SSL certificates
SAFRunAS, including CGIs (but not FastCGI)
SSL-related
z/OS System SSL exploitation
Other
SMP/E packaging; sample JCL
Recompiled WebSphere plug-in to run on z/OS under Apache
64-bit addressability
You have the ability to run Apache on z/OS, exploiting key z/OS
services, and run Tomcat alongside supporting servlets and JSPs
*In truth it ran on z/OS before, but it didn’t
exploit z/OS. That’s the work done in 2006
© 2012 IBM Corporation
or run … WebSphere Application Server for z/OS …
11
IBM Americas -- Advanced Technical Skills
WebSphere Application Server – The IBM Java EE Solution
An "application server" provides a common and standard set of services that
applications can use. Developers can focus on their business logic and not
have to "reinvent the wheel" basic stuff.
Application
Based on
industry
accepted
standards
Service
Service
Application
Service
Application
Service
Developer responsible for this
Service
Application Server
Vendor responsible for this
Operating System Platform
Tomcat is also an “application server,”
but one with a smaller set of standard
features and specs
WebSphere Application Server v8.5 for z/OS supports the Java EE 6 specification, including EJB 3.1
The concept is not new, but the cross-platform, industry-standard interfaces are what has made
this different from efforts in the past
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
12
6
The End
© 2012 IBM Corporation
IBM Americas -- Advanced Technical Skills
13
7
IBM – Java – z/Series Seminars
Lab 2: Short Break
Version of February 10, 2009
© Copyright 2009 International Business Machines Corporation
IBM – Java – z/Series Seminars
Please take a 10 minute break.
When you return, you will have completed this lab.
Lab: Break
Page 2 of 2
IBM Wildfire Series
z/OS Java Exploiters and Java Batch
Unit 3: Batch Java on z/OS
v
WSC Wildfire Class
Version of November 29, 2012
© 2012 IBM Corporation
IBM Wildfire Series
What can you do with Java in batch?
• Access:
• Databases - Java Database Connectivity (JDBC) to DB2, IMS, and
others
• Sequential datasets
• VSAM datasets
• HFS and ZFS files
• MQ
• Invoke:
• CICS transactions (CTG)
• TCP/IP socket services
• Run started tasks that wait for incoming work
• Produce bills, large reports, PDF files
2
© 2012 IBM Corporation
IBM Wildfire Series
Publications
 SG24-7779: Batch Modernization on z/OS (2009)
Chapter 5. Introduction to Java on z/OS
Chapter 6. Implement new functionality using Java in traditional containers
Chapter 7. Implement new functionality using stand-alone Java
Chapter 8. Implement new functionality using Java in WebSphere XD
Compute Grid
Chapter 9. Implement new functionality using PHP on z/OS
Chapter 10. Summary of new functional requirements in z/OS batch
 SG24-7177: Java Stand-alone Applications on z/OS - Volume 1 (2006)
 SG24-7291: Java Stand-alone Applications on z/OS - Volume 2 (2006)
3
© 2012 IBM Corporation
IBM Wildfire Series
Java for z/OS (JZOS)
• Incorporated into Java 5.0 SR3 and higher - October 2006
• Incorporated into Java 6.0 and Java 6.0.1 – all releases
• Features consist of:
• Batch Launcher
• Load module, proc, sample JCL are in mvstools subdirectory of Java library
• Must copy to MVS libraries and customize
cp JVMJCL61 "//'SYS1.SAMPLIB(JVMJCL61)'"
cp JVMPRC61 "//'SYS1.PROCLIB(JVMPRC61)'"
cp -X JVMLDM61 "//'SYS1.SIEALNKE(JVMLDM61)'“
• A set of Java classes to do “z/OS things”
• Various tools that improve interoperability with other languages
• Sample programs
4
© 2012 IBM Corporation
IBM Wildfire Series
Java for z/OS (JZOS) Documentation
• JZOS Installation and User’s Guide, SA23-2245
• Redbook: Java Stand-alone Applications on z/OS Volume II
• JZOS Cookbook 1.0.7
• All JZOS documentation is available at:
http://www-03.ibm.com/systems/z/os/zos/tools/java/products/jzos/overview.html
5
© 2012 IBM Corporation
IBM Wildfire Series
Some JZOS benefits
 JZOS Batch Launcher
– Invoked in Original Address Space
– STDOUT and STDERR route Directly to JES SYSOUT so you can monitor
the job while running using SDSF
– JZOS_OUTPUT_ENCODING envar overrides default lang encoding for
output
– Condition Codes Passed from System.exit() to Subsequent Steps
 VSAM dataset access
– Key-Sequenced Data Set (KSDS)
– Entry-Sequenced Data Set (ESDS)
– Relative Record Data Set (RRDS)
– But no Linear Data Set (LDS) support
 Lots of tips, samples, details, etc. in Redbook Java Stand-alone Applications
for z/OS Volume II (SG24-7291), chapters 3 and 7.
6
© 2012 IBM Corporation
IBM Wildfire Series
Sample JCL to Invoke JZOS Batch Launcher
//MYJOB JOB (?,?),'ZPDFSEND',MSGCLASS=O,CLASS=A,
//
NOTIFY=?,REGION=512M TYPRUN=HOLD
//*
//ZPDF EXEC PROC=JVMPRC61,LOGLVL='+N',JAVACLS='Zpdf‘,
//
ARGS=‘Student Grade Report’
//INDS
DD DSN=INPUTDS.TEST,DISP=SHR
//OUTPDF DD PATH='/output/myoutput.pdf',
//
PATHOPTS=(OWRONLY,OCREAT),PATHMODE=SIRWXU
//SYSPRINT DD SYSOUT=* <-Unix STDOUT messages
//SYSOUT
DD SYSOUT=* <-JZOS batch launcher messages
//STDOUT
DD SYSOUT=* <-Java System.out messages
//STDERR
DD SYSOUT=* <-Java System.err messages
//STDIN
DD DUMMY
<-Java System.in
7
© 2012 IBM Corporation
IBM Wildfire Series
Sample JCL to Invoke JZOS Batch Launcher
(continued)
//STDENV DD *
export JAVA_HOME=/usr/lpp/java/J6.1
export PATH=/bin:"${JAVA_HOME}"/bin:
LIBPATH=/lib:/usr/lib:"${JAVA_HOME}"/bin
export LIBPATH="$LIBPATH":"${JAVA_HOME}"/bin/classic
export CLASSPATH=/javaprogs:/javalibs/iText-5.0.6.jar
export IBM_JAVA_OPTIONS=“-mx256m”
iText® is a registered trademark of 1T3XT BVBA. See http://itextpdf.com for information about iText.
iText is not sponsored or endorsed by IBM. It is used in this presentation only to provide a Java batch
program example.
8
© 2012 IBM Corporation
IBM Wildfire Series
Sample Batch Java Program Fragment
import
import
import
import
import
import
import
java.io.*;
java.util.*;
com.ibm.jzos.ZFile;
com.ibm.jzos.ZUtil;
com.ibm.jzos.FileFactory;
com.itextpdf.text.pdf.PdfWriter;
com.itextpdf.text.*;
public class Zpdf {
public static void main(String[] args) throws Exception {
StringBuffer title = new StringBuffer(132);
if (args.length == 0) {
title.append("Created by Zpdf");
}
else {
int i = 0;
while(i < args.length) {
title.append(args[i] + " ");
i++;
}
}
String reportTitle = title.toString();
// Open the input dataset
ZFile zFilein = new ZFile("//DD:INDS",
"rb,type=record,noseek");
9
© 2012 IBM Corporation
IBM Wildfire Series
A few of the JZOS Classes
 DfSort
– An interface for invoking DFSORT to perform high-volume sort and merge
operations
 Exec
Class for running an external process that buffers output, provides timeout control and
stdout/stderr character encoding.
 File Factory
A class with static methods for building a BufferedReader, BufferedWriter, InputStream, or
OutputStream on a text file or MVS dataset.
 MvsConsole
A class with static methods to interface with the MVS console.
 MvsJobSubmitter
A class for submitting batch jobs to JES2 or JES3 from a Java program
10
© 2012 IBM Corporation
IBM Wildfire Series
More JZOS Classes
 PdsDirectory
A class for opening a PDS directory and iterating over its members.
 WtoMessage
A simple data object/bean for holding a WTO message and its
parameters.
 ZFile
JNI Wrapper for z/OS C-Library IO routines.
 ZUtil
Provides a static interface to various z/OS native library calls, other than
I/O.
11
© 2012 IBM Corporation
IBM Wildfire Series
Summing it up
 Java is often the most cost-effective language
– Advanced development tools
– Programmers available worldwide
– zAAP
 Extensive connection support
 JZOS provides enhanced Java batch support
 Moving forward:
– Batch Modernization on z/OS – SG24-7779
Covers WebSphere XD and other approaches
12
© 2012 IBM Corporation
IBM Wildfire Series
z/OS Java Exploiters and JAVA Batch
Lab 3: Java Batch Using JZOS
v
WSC Wildfire Class
© 2012 IBM Corporation
IBM Wildfire Series
JZOS Installation and Use Lab
 Java V6 is used in this lab
 Set up a JZOS batch job
– Verify JZOS installation by running HelloWorld program
 Use three JZOS functions
– Setting Condition Code from Java
– Write to Operator Console from Java
– Intercept Console “Modify” (F) command
14
© 2012 IBM Corporation
IBM Wildfire Series
Trademarks
The following are trademarks of the International Business Machines Corporation in the United States and/or other countries.
DB2*
DB2 Connect
DB2 Universal Database
e-business logo
GDPS*
Geographically Dispersed Parallel Sysplex
HyperSwap
IBM*
IBM eServer
IBM logo*
Parallel Sysplex*
System z
Tivoli*
VM/ESA*
WebSphere*
z/OS*
z/VM*
zSeries*
* Registered trademarks of IBM Corporation
The following are trademarks or registered trademarks of other companies.
Intel is a registered trademark of the Intel Corporation in the United States, other countries or both.
Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both.
Java and all Java-related trademarks and logos are trademarks of Sun Microsystems, Inc., in the United States and other countries.
UNIX is a registered trademark of The Open Group in the United States and other countries.
Microsoft, Windows and Windows NT are registered trademarks of Microsoft Corporation.
SET and Secure Electronic Transaction are trademarks owned by SET Secure Electronic Transaction LLC.
* All other products may be trademarks or registered trademarks of their respective companies.
Notes:
Performance is in Internal Throughput Rate (ITR) ratio based on measurements and projections using standard IBM benchmarks in a controlled environment. The actual throughput that
any user will experience will vary depending upon considerations such as the amount of multiprogramming in the user's job stream, the I/O configuration, the storage configuration, and
the workload processed. Therefore, no assurance can be given that an individual user will achieve throughput improvements equivalent to the performance ratios stated here.
IBM hardware products are manufactured from new parts, or new and serviceable used parts. Regardless, our warranty terms apply.
All customer examples cited or described in this presentation are presented as illustrations of the manner in which some customers have used IBM products and the results they may
have achieved. Actual environmental costs and performance characteristics will vary depending on individual customer configurations and conditions.
This publication was produced in the United States. IBM may not offer the products, services or features discussed in this document in other countries, and the information may be
subject to change without notice. Consult your local IBM business contact for information on the product or services available in your area.
All statements regarding IBM's future direction and intent are subject to change or withdrawal without notice, and represent goals and objectives only.
Information about non-IBM products is obtained from the manufacturers of those products or their published announcements. IBM has not tested those products and cannot confirm the
performance, compatibility, or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products.
Prices subject to change without notice. Contact your IBM representative or Business Partner for the most current pricing in your geography.
15
© 2012 IBM Corporation
IBM – Java – z/Series Seminars
Lab 3: JZOS Installation and Use
Last Updated: May 15, 2012
© Copyright 2012 International Business Machines Corporation
Lab Overview
In this lab, you will create and run a JZOS batch job the runs a “HelloWorld” program.
After the “HelloWorld” batch jobs runs successfully, you will use the run two additional
programs as batch jobs and one program as a started task, all under the JZOS batch
processor.
Exercise 1: Customize JZOS batch job
In this exercise, you will customize the sample JZOS batch job and run the sample
HelloWorld program in a batch job. This exercise must be completed successfully
before proceeding to the other exercises.
You MUST complete Exercise 1 successfully before proceeding to the other exercises
because files used in this step are used in subsequent labs.
_____ 1.
Set your /u/zeam01/.profile to use Java V6 64 bit (J6.0.1_64) by uncommenting the
appropriate export JAVA_HOME statement and commenting out the other JAVA_HOME
statements. (Actually, this lab will work with any release of Java.) For example:
#export JAVA_HOME=/usr/lpp/java/J5.0
#export JAVA_HOME=/usr/lpp/java/J5.0_64
export JAVA_HOME=/usr/lpp/java/J6.0.1_64
_____ 2.
Exit from OMVS, then go back into OMVS so that any changes that you made
to your .profile in step 1 (above) take effect.
_____ 3.
Verify that the change (if any) that you made in step work is working by
issuing the following command from an OMVS command line.
java –version
A response similar to the following should appear:
java version "1.6.0"
Java(TM) SE Runtime Environment (build pmz3160_26fp1-20110419_01)
IBM J9 VM (build 2.6, JRE 1.6.0 z/OS s390-31 20110418_80450 (JIT enabled,
AOT en
abled)
J9VM - R26_Java626_GA_FP1_20110418_1915_B80450
JIT - r11_20110215_18645ifx8
2
GC - R26_Java626_GA_FP1_20110418_1915_B80450
J9CL - 20110418_80450)
JCL - 20110401_01
_____ 4.
Exit from OMVS to get back to ISPF.
_____ 5.
Copy member SYS1.SAMPLIB(JVMJCL67) to ZEAM01.JCL.CNTL(JVMJCL67). Add a
job statement by issuing the JOBCARD command at the editor command line. Ensure that
the REGION size is set to 0M (or if you are a purist, some reasonable value).
Set the jobname (the first value) in the jobcard to your ZEAM’s name and number, followed
by any valid suffix character, for example: ZEAM01A.
Note: Question marks (?) can be left alone in the jobcard. Special exits on our lab system
handle the question marks.
//ZEAM01A JOB (?,?),’ZEAMS JOB’,MSGCLASS=O,CLASS=H,
//
_____ 6.
NOTIFY=?,REGION=0M
Next, we need to determine where the Java product is located on the system. Since the
Java virtual machine is part of the Java product, we can find the location of the Java product
if we know where the java command is located. Find the location of the java command by
issuing whence java at an OMVS command line. Write the pathname for the java
command below.
________________________________________________________________
_____ 7.
The Java product directory is located in the directory just above the bin directory that
contains the java command. On the lab system, the Java product directory
is /usr/lpp/java/J6.0.1_64 (or its symbolic link, /shared/java/J6.0.1_64). Please keep
this in mind for future steps.
Again, what is the name of the Java program directory? (Typically - /usr/lpp/java/J6.0.1_64)
_____________________________________________________
3
_____ 8.
Verify that JAVA_HOME in your JVMJCL67 member is set to the location of the Java
product directory (that you noted in step 7, above). Typically, you would specify:
export JAVA_HOME=/usr/lpp/java/J6.0.1_64
_____ 9.
The sample Java class that you will execute is called HelloWorld. The HelloWorld class
is included in the JZOS library that is part of Java for z/OS, so you do not need to create
your own HelloWorld program. Verify that JAVACLS=’HelloWorld’ is set as a parameter
on the EXEC statement in the JCL.
_____ 10.
Verify that the APP_HOME environment variable set to $JAVA_HOME. The
APP_HOME environment variable is used to set the CLASSPATH for the job. Setting
APP_HOME to $JAVA_HOME puts HelloWorld in the CLASSPATH for this job.
APP_HOME=$JAVA_HOME
_____ 11.
Save and SUBMIT the job.
_____ 12.
Using SDSF, issue the H command to check the HELD queue and verify that the results
are similar to those shown below. Tip: A good shortcut for accessing SDSF is the D
command from ISPF.
The program’s output should be Hello World.
JVMJZBL1001N JZOS batch Launcher Version: < >
JVMJZBL1002N Copyright (C) IBM Corp. 2005. All rights reserved.
java version "1.6.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pmz31dev-< > (SR<>-0
IBM J9 VM (build 2.3, J2RE 1.6.0 IBM J9 2.3 z/OS s390-31 j9vmmz3123-20081130 (JI
J9VM - 20081126_26240_bHdSMr
JIT - 20121112_1511ifx1_r8
GC - 2012811_07)
JVMJZBL1023N Invoking HelloWorld.main()...
JVMJZBL1024N HelloWorld.main() completed.
JVMJZBL1021N JZOS batch launcher completed, return code=0
Hello World
_____ 13.
If your results are similar to those shown in step 12, then you have verified that JZOS is
installed and you now have a working batch job that can be used to run other Java
programs in batch. Proceed to step 15.
4
_____ 14.
If the job gets a nonzero return code, change the LOGLVL parameter to +T and run the
job again. The job will now contain trace data and you should be able to use the trace data
to determine the cause of the problem. Make corrections, then go back to step 12.
_____ 15.
Change the LOGLVL parameter +I to become familiar with the Java batch Information
trace option.
_____ 16.
Save and SUBMIT the job. Examine the output using SDSF.
_____ 17.
Change the LOGLVL parameter +T to become familiar with the Java batch Trace option.
_____ 18.
Save and SUBMIT the job. Examine the output using SDSF.
_____ 19.
Set LOGLVL back to +N so that excessive output is not generated in the remaining
steps of this lab. If you have problems in subsequent lab steps, you can set LOGLVL to +I
or +T to viewing detailed trace information.
5
Exercise 2: Setting the Condition Code Lab
In this exercise, you will compile and run a Java program that sets a condition code at termination.
_____ 1.
Logon to TSO as zeam01 and go to PDF Option 6
_____ 2.
Enter OMVS (or use Putty and vi)
_____ 3.
Set your current directory to your jzoslabs directory by entering the following command.
cd /u/zeam01/jzoslabs
_____ 4.
Enter ls –al *.java
You should see the following files:
_____ 5.
-rw-r—r--
1 <zeam>
INTERNS
329 Oct 11 14:17 ExitCC.java
-rw-r—r--
1 <zeam>
INTERNS
1696 Oct 11 14:17 Modify.java
-rw-r—r--
1 <zeam>
INTERNS
459 Oct 11 14:17 WTO.java
Edit the ExitCC.java program by entering oedit ExitCC.java.
You should see the following:
// NAME = ExitCC.java
//
// DESCRIPTIVE NAME = Exit java with a Condition Code
//
// ExitCC:
//
// (a) JZOS Sample to Exit with a Condition Code processable by JCL
//
public class ExitCC
{
public static void main( String[] args )
{
System.exit( 2005 ); // Set condition code
} // end of main
} // end of ExitCC
_____ 6.
Change 2005 to any reasonable integer value. You should set it to a value under 32767
because return codes are only 15 bits long. If you can’t think of a good number to use, then
use 28.
_____ 7.
Press F3 to exit from the editor.
_____ 8.
Compile the ExitCC.java program by entering the following command:
javac ExitCC.java to compile the class.
6
If compilation is successful, then a new OMVS prompt will be displayed. If compilation is
not successful, then correct any errors and recompile.
_____ 9.
_____ 10.
Exit from OMVS.
Edit ZEAM01.JCL.CNTL(JVMJCL67) and make the following changes:
Update JAVACLS to point to ExitCC as shown below:
// JAVACLS=’ExitCC’
Update the APP_HOME environment variable to point to your zeam’s
classes directory as shown below.
APP_HOME=/u/zeam01/jzoslabs
_____ 11.
Save and SUBMIT the job.
_____ 12.
Using SDSF, examine the output. Verify that the job terminated with the condition code that you
specified. The output should be similar the following, with the last line of output showing the return
code that you set in the Java program.
IEF376I JOB/ZEAM01A /STOP 2009035.1627 CPU
0MIN 00.75SEC SRB
0MIN 00.01S
JVMJZBL1001N JZOS batch Launcher Version: 2.3.0 2008-05-12
JVMJZBL1002N Copyright (C) IBM Corp. 2005. All rights reserved.
java version "1.6.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pmz31dev20081210 (SR9-0
IBM J9 VM (build 2.3, J2RE 1.6.0 IBM J9 2.3 z/OS s390-31 j9vmmz312320081130 (JI
J9VM - 20081126_26240_bHdSMr
JIT - 20081112_1511ifx1_r8
GC
- 200811_07)
JVMJZBL1023N Invoking ExitCC.main()...
JVMJZBL1043N The Java virtual machine completed with System.exit(28)
_____ 13.
You have completed this lab exercise.
7
Exercise 3: Write to Operator Lab
In this exercise, you will compile and execute a Java program that writes to the z/OS
operator console.
_____ 1.
Logon to TSO as ZEAM01 and go to PDF Option 6.
_____ 2.
Enter OMVS
_____ 3.
Enter cd $HOME/jzoslabs
_____ 4.
The WTO.java program is shown below.
You should see the following:
//
//
// NAME = WTO.java
//
// DESCRIPTIVE NAME = Issue Write to Operator (WTO) from java
//
// ExitRC:
//
// (a) JZOS Sample to issue a WTO
//
import com.ibm.jzos.*;
public class WTO
{
public static void main( String[] args )
{
MvsConsole.wto(“ZJAV000I Current job is ‘” +
ZUtil.getCurrentJobname() + “’.”,
0x0020, // route code
0x4000); // descriptor code
} // end of main
} // end of WTO
This program will issues a WTO message to the console with the JOBNAME.
_____ 5.
Enter javac WTO.java to compile the WTO.java class.
_____ 6.
Exit from OMVS.
_____ 7.
Edit ZEAM01.JCL.CNTL(JVMJCL67) as follows:
Update JAVACLS
// JAVACLS=’WTO’
_____ 8.
Save and SUBMIT the job.
_____ 9.
Verify results with sample that the message appeared on the system console by issuing the
SDSF LOG command. A message similar to the following should appear on the console:
*BPXM023I (ZEAM01) ZJAV000I Current job is ‘ZEAM01A’
_____ 10.
You have completed this lab exercise.
8
1
Exercise 4: Modify Command Interceptor Lab
In this exercise, you will compile and execute a Java program that is capable of
reading z/OS console “Modify” (F) commands. The Java program will be run as a
started task. You will then send the program a Modify (F) command and verify that
the program received the command.
_____ 1.
Logon to TSO as ZEAM01 and go to PDF Option 6.
_____ 2.
Enter OMVS
_____ 3.
Enter cd $HOME/jzoslabs
_____ 4.
The Modify.java program is shown below. You should see the following:
//
// NAME = Modify.java
//
// DESCRIPTIVE NAME = Process a Modify (F) operator command in
java
//
// Modify:
//
// (a) JZOS Sample to process a Modify operator command
// (b) Loops 60 times at 10 second intervals to allow:
//
Modify and Stop commands to be entered.
//
import java.lang.*;
import java.util.*;
import com.ibm.jzos.*;
public class Modify extends Thread
{
public static void main( String[] args ) throws InterruptedException
{
int loop = 60;
long interval = 10000; /* Ten seconds */
System.out.println(“Calling regMVSCommand();”);
regMVSCommand();
/* Register the Command Callback */
System.out.println(“Called regMVSCommand();”);
while (loop >= 0)
/* Loop to display Modify commands */
{
System.out.println(loop + “. The time is now “ +
new Date() + “.”);
sleep(interval);
loop--;
} // end of while
} // end of main
public static void regMVSCommand()
{
9
System.out.println(“Registering MvsCommandCallback”);
MvsConsole.registerMvsCommandCallback(new
MvsCommandCallback()
{
public void handleModify(String modifyCommand)
{
System.out.println(“Modify command: “ + modifyCommand);
} // end of handleModify
public void handleStart(String startCommand)
{
System.out.println(“Started with “ + startCommand);
} // end of handleStart
public boolean handleStop()
{
boolean tf=true;
System.out.println(“Stop Command received”);
return(tf);
} // end of handleStop
} // new MvsCommandCallback()
); // end of ZUtil.setMvsCommandCallback
System.out.println(“Registered MvsCommandCallback”);
} // end fo regMVSCommand
} // end of Modify
_____ 5.
The above program will loop for 10 minutes displaying the current time every 10 seconds.
When a modify (F) console command is issued, it will display the modify parameters. The
output is routed to the job log.
_____ 6.
Enter javac Modify.java to compile the class.
_____ 7.
Exit from OMVS by entering exit.
_____ 8.
Next, you will create ZEAM01.JCL.CNTL(STDENV) as follows. Steps a to e that follow
immediately below are a shortcut for creating the STDENV environment variable member.
a. Copy member ZEAM01.JCL.CNTL(JVMJCL67) into member
ZEAM01.JCL.CNTL(STDENV). (This is to save you a LOT of typing.) Do
not use any name other than STDENV for the member.
b. Delete from line 1 of the member to and including //STDENV DD *
c. Delete the last line which should be //
d. Update the pathname setting for the Java SDK in environment variable
JAVA_HOME so that it points to the pathname for Java on this system.
e. Update the environment variable named APP_HOME to point to
/u/zeam01/jzoslabs directory.
_____ 9.
Press F3 to exit from the editor.
10
_____ 10.
In the next step, you will Start a started task proc called JZOSSTC. You can look at the
started task proc in SYS1.PROCLIB(JZOSSTC), but please do not make any changes to the
proc.
_____ 11.
From SDSF, enter the following console command.
/s jzosstc,jobname=zeam01,zeam=zeam01
Note: JZOSSTC is a proc that references the jobname and zeam parameters. You do not
need to create or modify the JZOSSTC proc. (If you want to view the JSOSSTC proc, it is
in SYS1.PROCLIB.)
_____ 12.
Ensure that the SDSF “owner” filter is set to “*”. To set the “owner” filter, issue:
OWNER *
_____ 13.
To limit the jobs displayed to just ZEAM01 jobs, enter the following SDSF command:
PRE zeam01*
_____ 14.
To display your zeam’s jobs, enter the following SDSF command:
DA
_____ 15.
If there is no job named zeam01 executing, you will need to:
Enter ST or LOG and determine the problem
Enter ? next to the executing task zeam01
Enter S next to STDOUT
_____ 16.
You should see something similar to:
Calling regMVSCommand();
Registering MvsCommandCallback
Started with
Registered MvsCommandCallback
Called regMVSCommand();
Called regMVSCommand();
60. The time is now Fri Oct 28 12:36:13 EDT 2011.
59. The time is now Fri Oct 28 12:36:23 EDT 2011.
58. The time is now Fri Oct 28 12:36:33 EDT 2011.
57. The time is now Fri Oct 28 12:36:43 EDT 2011.
56. The time is now Fri Oct 28 12:36:53 EDT 2011.
55. The time is now Fri Oct 28 12:37:03 EDT 2011.
54. The time is now Fri Oct 28 12:37:13 EDT 2011.
53. The time is now Fri Oct 28 12:37:23 EDT 2011.
52. The time is now Fri Oct 28 12:37:33 EDT 2011.
51. The time is now Fri Oct 28 12:37:43 EDT 2011.
11
_____ 17.
Enter a couple of modify commands, as shown below:
/f zeam01,appl=SOME GOOD STUFF
/f zeam01,appl=SOME MORE GOOD STUFF
_____ 18.
Verify results with sample below from SDSF
The time is now Fri Oct 28 13:43:48 EDT 2011.
Modify command: APPL=SOME GOOD STUFF
The time is now Fri Oct 28 13:43:58 EDT 2011.
Modify command: APPL=SOME MORE GOOD STUFF
_____ 19.
Enter /p zeam01 to stop the started task
_____ 20.
You have completed this lab exercise.
12
IBM System z Wildfire Seminars
z/OS Java Exploiters and Java Batch
Unit 4: WebSphere Batch
v
Last updated: 2012-11-27
© 2012 IBM Corporation
Credit: Don Bagwell
Several Different Approaches
There are different ways to approach “Java Batch”
Java Batch
Container Model
JVM Launcher
Solutions
Standalone
Java Program
•
•
•
Simple programming
model
Launch with “java”
command at the shell
Developer responsible
for everything
© 2012 IBM Corporation
•
•
•
•
•
Example is JZOS
JVM Launcher provides
helpful functions
•
Developer may still
need to code functions
not provided by
launcher
Example is IBM WebSphere
XD Compute Grid
Provides batch programming
framework as services of the
platform
Allows developer to focus on
the business logic and not
“custom middleware”
All are perfectly good approaches,
depending on the nature of the batch
processing you are doing
IBM Amercas – Advanced Technical Skills
2
1
IBM's Batch Container Approach
At a high-level the IBM Batch Container is an extension to the
existing container structure of WebSphere Application Server
This is what IBM delivers
in the form of its Java
Batch solutions (FeP or
WCG)
Batch
Program
Application
Server
© 2012 IBM Corporation
Vendor-supplied code
that implements the
functional interfaces
Web
Container
EJB
Container
Vendor-supplied code
that implements the
functional interfaces
Vendor-supplied code
that implements the
functional interfaces
Credit: Don Bagwell
IBM Amercas – Advanced Technical Skills
3
Basic WebSphere Batch Environment
© 2012 IBM Corporation
IBM Amercas – Advanced Technical Skills
4
2
1. Job Scheduler
•
Provides all job management functions
• Submit
• Restart
• Cancel
Maintains waiting jobs, running jobs, finished jobs
Hosted in WAS environment
Only one per cell
•
•
•
2. Batch Container – Grid Endpoint (GEE)
•
•
Provides execution environment for your batch jobs
Hosted in WAS environment
3. Java EE Batch Application
•
•
Regular Java EE application
Deployed as an ear file through the WAS ISC
© 2012 IBM Corporation
IBM Amercas – Advanced Technical Skills
5
4. xJCL
•
•
XML-based job control language
xJCL provides a way to describe (“declare”)
what makes up the elements of a “job”
<job xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://core.wcg.etools.ibm.com/xsd/xJCL.xsd"
name="BatchFileIO" default-application-name="BatchFileIOEAR">
<jndi-name>ejb/BatchFileIOJob_1BatchController</jndi-name>
<checkpoint-algorithm name="checkpoint">
<classname>com.ibm.wsspi.batch.checkpointalgorithms.timebased</classname>
<props>
<prop name="TransactionTimeOut" value="60"/>
<prop name="interval" value="120"/>
</props>
</checkpoint-algorithm>
<job-step name="ReadWriteStep">
<classname>com.ibm.websphere.batch.devframework.steps.technologyadapters.GenericXDBatchStep</classname>
<checkpoint-algorithm-ref name="checkpoint"/>
<batch-data-streams>
<bds>
<logical-name>inputStream</logical-name>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.TextFileReader</impl-class>
<props>
<prop name="FILENAME" value="${inputFilename}"/>
<prop name="PATTERN_IMPL_CLASS" value="com.ibm.wsc.inputstream.TextFileReader"/>
<prop name="file.encoding" value="${file.encoding}" />
<prop name="AppendJobIdToFileName" value="${AppendJobIdToFileName}" />
</props>
</bds>
<bds>
<logical-name>outputStream</logical-name>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.TextFileWriter</impl-class>
<props>
<prop name="FILENAME" value="${outputFilename}"/>
<prop name="PATTERN_IMPL_CLASS" value="com.ibm.wsc.outputstream.TextFileWriter"/>
<prop name="file.encoding" value="${file.encoding}" />
<prop name="AppendJobIdToFileName" value="${AppendJobIdToFileName}" />
</props>
</bds>
</batch-data-streams>
<props>
<prop name="BATCHRECORDPROCESSOR" value="com.ibm.wsc.processor.BatchRecordProcessor"/>
</props>
© 2012 IBM
Corporation
IBM Amercas – Advanced Technical Skills
</job-step>
</job>
6
3
5. Web, Shell, API
Different Ways to Manage Jobs
WAS Native
Job
Management
Console
Command
Line
Interface
Custom Interfaces
EJB
Interface
Web
Services
Interface
© 2012 IBM Corporation
IBM Amercas – Advanced Technical Skills
7
6. Scheduler Tables
•RDB (e.g., DB2) used to hold job information
7. Container Tables
•RDB (e.g., DB2) used to store checkpoint information
8. JDBC
•How JS and batch container communicates with data store
© 2012 IBM Corporation
IBM Amercas – Advanced Technical Skills
8
4
Job
Repository
WAS Server
Job
Scheduler
xJCL
MailerTopJob.xml
STATES_LIST=AZ,AL,HI,MN…
Parallel Job Manager
•
WAS Server 1
Grid
Endpoint
•
Batch App
•
SubJob # 1
•
WAS Server
…
Sub job
name
Batch
Container
Target of a parallel job
• PJM does not process any
batch data streams
• Monitors and manages subjobs (which are submitted to
the JS)
Subjobs are aggregated by the
PJM into one logical top level job
Not a required component on
WCG v6.1.1
Installed by default on WCG v8 &
WAS 8.5
STATES_LIST=VA,WA,TX…
WAS Server N
MailerSubJobName
Parallel
Job Manager
Grid
Endpoint
Parameterizer
SPI
50 states / 4 jobs
Returns Properties[4] Each with
STATES_LIST=different states
Sub-job
xJCL
Batch App
SubJob # N
© 2012 IBM Corporation
IBM Amercas – Advanced Technical Skills
9
Integration with Enterprise Schedulers
JCL or
shell script
Job Dispatcher
WSGrid
Client
Utility
Grid Endpoint
MDB
Interface
If your workload scheduler is capable of submitting JCL or
invoking a shell script, it can submit a job into WebSphere
Batch
© 2012 IBM Corporation
IBM Amercas – Advanced Technical Skills
10
5
Checkpoint & Restart
• Used to determine when to commit global transactions
• On each iteration of processJobStep() method (found in custom job step or
GenericXDBatchStep or ETS), GEE consults checkpoint algorithm
Time-based algorithm – commit at specified time interval
Checkpoint
Interval: 120 seconds
120s
Job
complete!
120s
120s
120s
Record-based algorithm – commit at specified # of records
Checkpoint
Interval: 1000 records
1000
1000
900
Job
complete!
© 2012 IBM Corporation
IBM Amercas – Advanced Technical Skills
11
WebSphere Batch Programming Models
Compute-intensive Model
Job complete!
Calculate
Submit CI job
Batch Programming Model
Input
Job complete!
Submit batch job
Output
© 2012 IBM Corporation
IBM Amercas – Advanced Technical Skills
6
IBM Offers Two Solutions
Layered “entry point” strategy
IBM Feature Pack for Modern Batch
•
•
•
No-charge feature pack to WAS v7
A subset of the function provided by Compute Grid
Function rolled into WAS v8
IBM WebSphere XD Compute Grid
•
•
•
Pre-reqs WAS v7 as its runtime base
Separate licensed program product
Everything the Feature Pack has and more
Credit: Don Bagwell
© 2012 IBM Corporation
IBM Amercas – Advanced Technical Skills
13
FeP for Modern Batch vs WCG
© 2012 IBM Corporation
IBM Amercas – Advanced Technical Skills
14
7
References
WebSphere Extended Deployment Compute Grid ideal for handling
mission-critical batch workloads
http://www.ibm.com/developerworks/websphere/techjournal/0804_antani/0804_antani.html
CCR2 article on SwissRe and Compute Grid
http://www-01.ibm.com/software/tivoli/features/ccr2/ccr2-2008-12/swissre-websphere-compute-grid-zos.html
WebCasts and Podcasts on WebSphere XD Compute Grid
http://snehalantani.googlepages.com/recordedinterviews
Java Batch Programming with XD Compute Grid
http://www.ibm.com/developerworks/websphere/techjournal/0801_vignola/0801_vignola.html
WebSphere Compute Grid Frequently Asked Questions
http://www-128.ibm.com/developerworks/forums/thread.jspa?threadID=228441&tstart=0
Development Tooling Summary for XD Compute Grid
http://www.ibm.com/developerworks/forums/thread.jspa?threadID=190624
Compute Grid Discussion forum
http://www.ibm.com/developerworks/forums/forum.jspa?forumID=1240
Compute Grid Trial Download
http://www.ibm.com/developerworks/downloads/ws/wscg/learn.html?S_TACT=105AGX10&S_CMP=ART
Compute Grid Wiki (product documentation)
http://www.ibm.com/developerworks/wikis/display/xdcomputegrid/Home?S_TACT=105AGX10&S_CMP=ART
© 2012 IBM Corporation
IBM Amercas – Advanced Technical Skills
15
8
IBM System z Wildfire Seminars – ZJAV1 – Java Exploiters
WebSphere Batch Labs - System Information for z/OS
You will customize WebSphere® Compute Grid V8.5 for z/OS (WCG.) This handout
contains information you may find useful for the labs.
Basic workshop system information:
q
q
q
q
q
q
System name
Sysplex name
Operating System Level
System proclib
System EXEC library
System parmlib
WG31
WSLPLEX
z/OS R13
SYS1.PROCLIB
SYSS.WSC.SYSEXEC
SYSS.PARMLIB
TCP/IP Information:
q
q
q
q
q
TCPIP host name
WG31
TCP/IP fully qualified host name
wg31.washington.ibm.com
Windows XP hosts file location
C:\WINDOWS\system32\drivers\etc\hosts
TCP/IP addresses for WG31 hosts: (verify with “ping WG31” from TSO command line)
q Team x
192.168.17.2_x
TCP/IP ports:
q
FTP port
21
q
SSH
22
q
TN3270 port
23
q
Telnet port to USS
1023
Userid Information:
The following TSO UserIDs are already defined for you. (pw = userid.)
USERID
GROUPID
UID
Home
User with DB2 SYSADM authority
SYSADM1
SYS1
0
/u/sysadm1
User with RACF Special authority
USER1
SYS1
8470391
/u/user1
Other TSO user
USER2
SYS1
8470392
/u/user2
WAS Administrator
Z8ADMIN
Z8CFG
20001
/wasv85config
/z8cell/home
/Z8CFG
Note: SYSADM1 should only be used for activities that explicitly require SYSADM authority.
USER0 should be used to submit jobs requiring “Superuser” access. USER1 can switch to
“Superuser” mode when explicitly required.
WebSphere V8.5 Library Information:
§ WAS for z/OS level
Version 8.5.0 (includes WCG)
§ WAS SMP/E home directory /shared/zWebSphere/V8R5
11/27/2012
WSC Lab System Information
Page 1
IBM System z Wildfire Seminars – ZJAV1 – Java Exploiters
WebSphere Configuration Information:
WAS servers are already configured for these labs with the following settings:
§
HFS Config roots:
OMVS.WG31.Z8CELL.Z8DMNODE.CONFIG.ZFS mounted at /wasv85config/z8cell/z8dmnode
OMVS.WG31.Z8CELL.Z8NODEA.CONFIG.ZFS mounted at /wasv85config/z8cell/z8nodea
§
§
§
§
§
§
§
Cell name
Z8CELL
(long name = z8cell)
Node name
Z8NODEA
(long name = z8nodea)
Scheduler Server name Z8DISPA
(long name = z8dispa)
Endpoint Server name
Z8ENDPA
(long name = z8endpa)
Admin Userid
Z8ADMIN
Ports
20000 – 20099
Start/Stop Commands:
§
Start RRS: s atrrrs,sub=mstr
§
Start DB2: -dsn9 start db2
§
Start CICS: s cics
§
Start MQ: -mqs1 start qmgr
§
Start WAS DMgr & NodeAgent:
s z8dcr,env=z8cell.z8dmnode.z8dmgr,jobname=z8dmgr
s z8acra,env=z8cell.z8nodea.z8agnta,jobname=z8agnta
ISC login: http://wg31.washington.ibm.com:20005/ibm/console
JMC login: http://wg31.washington.ibm.com:20067/jmc
DB2 Information:
§ DB2 level
§ DB2 subsystem name
§ DB2 communication char string
§ DB2 location name
§ DB2 library names
§ DB2 customized SDSNEXIT library
§ DB2 customized RUNLIB library
§ DB2 home directory
§ Start DB2 (MVS) Command:
Version 9
DSN9
-DSN9
WG31DB2
DSN910.**
DSN910.SDSNEXIT
DSN910.RUNLIB.LOAD
/shared/db2910_jdbc
-dsn9 start db2
CICS Information:
§ CICS level
§ CICS subsystem name
§ CICS APPLID
§ Start CICS (MVS) Command
CICS TS/4.2
CICS42
CICS42
s cics42
MQ Information:
§ MQ level
§ Start MQ (MVS) Command:
§ Queue Manager Name
§ Input Queue for WAS
§ Output Queue for WAS
11/27/2012
IBM WebSphere MQ for z/OS V7.0.1
-MQS1 START QMGR
MQS1
WASIQ
WASOQ
WSC Lab System Information
Page 2
IBM System z Wildfire Seminars – ZJAV1 – Java Exploiters
Workstation Set-up
•
C:\ComputeGrid\ folder for work files
•
WCG01 Folder on Desktop for PDF files
•
•
RAD V8
Set HOSTS file to use unique WG31 host address
o
C:\WINDOWS\system32\drivers\etc\hosts
192.168.17.2xx
•
wg31.washington.ibm.com
wg31
PCOM 3270 sessions more friendly (WG31.WS profiles):
o
Make sure Icons are on the desktop for ‘user’
o
Fix PCOM profiles for good keyboard and char-set mapping to
display brackets & braces:
 Wide WG31.WS - Large screen 50 x 132
 kens.KMP – keyboard mapping
TCPIP profile for large screen – in
DSN=SYS1.TCPPARMS(PROFILEx)
TELNETDEVICE DYNAMIC ,D4C32XX3
•
o
o
(See Techdoc TD102151 “Creating dynamic 3270 screen size
definitions for increased productivity”)
•
TeraTerm - correct backspace in Setting- Keyboard - uncheck Bksp
•
Putty - correct backspace in Settings - Keyboard – Bksp = Ctl-H
•
PFE Editor
•
WS_FTP LE – A GUI FTP client
System Set-up
HFS set-up:
• Put all .ear & sh files in /u/user1/cgwork/
Datasets used to build the z8cell:
USER1.Z8CELL.Z8DMNODE.CGAUG.CNTL
USER1.Z8CELL.Z8DMNODE.CGAUG.DATA
USER1.Z8CELL.Z8DMNODE.CNTL
USER1.Z8CELL.Z8DMNODE.DATA
USER1.Z8CELL.Z8EMPTYA.CGAUG.CNTL
USER1.Z8CELL.Z8EMPTYA.CGAUG.DATA
USER1.Z8CELL.Z8EMPTYA.CNTL
USER1.Z8CELL.Z8EMPTYA.DATA
Members in USER1.WAS.CNTL:
• SPFIVT – SPUFI DDL for IVT Table
• SPFLREE – SPUFI DDL for Endpoint Tables
• SPFLRS – SPUFI DDL for Dispatcher Tables
• SMFRMF – Single job to Dump SMF, run reports for RMF, and SMF 120 & 120.20
• WSGRID - Sample WSGRID job for WCG Scheduler Lab
11/27/2012
WSC Lab System Information
Page 3
IBM System z Wildfire Seminars – ZJAV1 – Java Exploiters
Other Members in USER1.WAS.CNTL :
• CICSSEC – Job to create RACF classes and profiles for CICS (Security Wkshp)
• DB2GRANT – Sample job to create GRANTs for PolicyIVP App (used by WBSR7)
• DB2JOB - Sample DB2 job for WCG – looks familiar, but don't know who uses it.
• DEFALIAS – Sample job to define an alias
• DEFCAT - Sample job to create a USERCAT (has my ID on it, but don't need)
• DUMPSMF – Job to dump SMF data from SYS1.MAN1 or MAN2 to USER1.SMF.DATA
• MQDISP – Old Sample job to issue MQ Display commands?
• RMFWAS – Sample job to create RMF Workload Activity Report
• SECTRAN – Create Profiles for CICS (Security Wkshp)
• SMFDETLR – Job to run the SMF 120 Browser for Detailed records
• SMFSUM - Sample job run SMF Browser for SMF 120 records in USER1.SMF.DATA
• SMF120 - Run SMF Browser for SMF 120 records in USER1.SMF.DATA
• SMF12020 Run SMF Browser for SMF 120 subtype 20 records for Batch job Usage #s
11/27/2012
WSC Lab System Information
Page 4
IBM System z Wildfire Seminars – ZJAV1 – Java Exploiters
Misc Information for all Labs
Handy MVS Commands
Here are a few useful MVS commands you may find helpful. Type a slash ('/') before them when issued
from SDSF command line, but not if entered from the SDSF “System Command Extension.”
Display Commands:
d a,z8*
active jobs starting with "Z8"
d asm,page=all
page data sets & utilization of page space
dd
dump data sets
d grs,c
global resource serialization - contention
d iplinfo
ipl time & bootstrap parms
d j,all
all jobs running on the system
d logger,l
logger logstreams
dm
CPUs (m=cpu), Memory (m=stor) & Channels
d parmlib
parmlib data sets used for this IPL
d omvs,a=all
UNIX address spaces (processes)
d omvs,f
HFS/zFS file systems currently in use or mounted
d omvs,mf
HFS/zFS Mount Failures
d omvs,o
UNIX current configuration settings
d omvs,p
PFS (physical file system) configuration information
d omvs,pid=nnnn
Processes with accumulated CPU time
d omvs,w
Delays (Waiters) for latch contention & WTORs
d opdata
operator command prefixes
d r,l
outstanding WTORs (Write To Operator with Replys)
d rrs
Resource Recovery Services
d smf
SMF recording dataset status
d symbols
system symbolics
dt
Time & Date (Local & GMT)
d tcpip,,n,portl
TCP/IP ports being listened on
d tcpip,,n,routes
TCP/IP routes
d tcpip,,n,home
TCP/IP home
d trace
all trace settings
d u,dasd,online,,99 online dasd devices
d wlm,dynappl=*
dynamic application environments
d xcf,cpl
XCF parameters and couple data sets
$dspl
JES2 spool utilization
11/27/2012
WSC Lab System Information
Page 5
IBM System z Wildfire Seminars – ZJAV1 – Java Exploiters
Other MVS Commands:
Start RRS
start atrrrs,sub=mstr
Stop RRS
setrrs cancel
Start MQ
-mqs1 start qmgr parm(mqs1zprm)
Stop MQSeries
-mqs1 stop
Disable ARM
setxcf stop,policy,type=arm
Start RMF
s rmf
Start data gatering
f rmf,s iii
Modify RMF interval
f rmf, Modify zz,SYNC(RMF,0), interval(2M)
Switch SMF datasets
i smf
Switch to new SMF parms set smf=99
Clear SMF dataset
s clrsmf,man=1 {or man=2}
Display TCP/IP Ports
d tcpip,,n,portlist
Display TCP/IP V6 setting
d tcpip,,netstat,home
Refresh TCP/IP Profile parms v tcpip,,o,sys1.tcpparms(profilex)
PAGEADD cmd to relieve storage shortage: PA PAGE=PAGE.WSL003.LOCAL
DB2 Commands:
Start DB2
Stop DB2
Display Threads
Cancel threads
-dsn9 start db2
-dsn9 stop db2
-dsn9 dis thd(*)
-dsn9 can thd(nn)
send 'msg',u=(userid) Send message to TSO user
11/27/2012
WSC Lab System Information
Page 6
IBM System z Wildfire Seminars – ZJAV1 – Java Exploiters
Useful Unix Commands:
General:
man <cmd>
exit
df
set –o vi
su
su <userid>
use "help" facility for <cmd>
exit the UNIX shell (or exit Super User State)
display file systems
make the vi editor handle command mode (j/k = up/down stack)
switch to priviledges of a superuser
switch to priviledges of another userid
Managing Directories
pwd
ls -al
cd <dir>
rmdir <dir>
mkdir -p sub1/sub2
chmod 755 *.*
chown owner path
list current directory
list contents of the current directory
change to directory ‘dir’
remove (delete) a directory
create sub-directories
grant authority to access your directory
change ownership of a file (-R option for subdirects)
Working with Files
cat filename
find . –name “xy*”
head filename
tail filename
obrowse filename
oedit filename
cp fromfile tofile
sort myfile >sout
rm old.txt
egrep "string" xx.yy
list the file
list all files starting with “xy” in this directory or any sub directories
display first 10 lines of a file
display last 10 lines
browse a file
edit a file (ISPF editor)
copy a file, specify from/to
sort "myfile" into "sout" file
remove (delete) a file (old.txt)
search for "string" in file "xx.yy"
File Transfer
ftp <hostname>
bin <or> ascii
lcd <loc-dir>
cd <rem-dir>
pwd
prompt
get <filename>
mget <file-list>
put <filename>
mput <file-list>
quit
11/27/2012
connect to remote host to get or put files
set Binary or ASCII/EBCDIC mode
change to local directory
change to remote directory
display present working directory
sets prompting mode on/off (toggle)
get a remote filename from the remote host
get multiple files
put file onto remote host
put multiple files
exit FTP
WSC Lab System Information
Page 7
IBM System z Wildfire Seminars – ZJAV1 – Java Exploiters
Visual Editor (vi) cheat-sheet
This page shows you some commonly used vi commands to edit a file. For a complete list of commands,
see “Learning the vi Editor” (O’Reilly), or type “man vi” in the UNIX shell (if it works)
Edit a file:
vi filename.ext
Edit filename.ext with the vi editor
:set all Display settings.
:set nu Set line numbering on (:set nonu turns it off)
:set ic Ignore case (:set noic turns it off)
:set showmode Show the editing mode at the bottom of the screen
:q!
:w
:wq
:r fn
:w fn
Quit editing without saving.
Save the file, and continue in edit.
Save the file and then exit editing.
Get (retrieve) file named ‘fn’.
Put (write) to file named ‘fn’.
Moving around in a file:
G
Move to bottom the file
1G
Move to the top of the file
Ctrl-F
Move forward one page (screen)
Ctrl-B
Move backwards on page
/abcd
Search forward for string “abcd”
?efgh
Search backward for string “efgh”
n
Find next occurrence (after a search command)
%
Find matching brace { -- }
Text Insertion Commands: (lower case and Upper Case meanings)
a A Enters insert mode after the current cursor position/A= at end of line (= $a).
i I
Enters insert mode before the current cursor position/before 1st nonblank char (= [i)
o O Opens up a new line after/before the current line and enters insert mode on it.
r R
Replaces characters with the next character typed/chars typed until ESC.
Object Manipulation:
y
Moves the object to the appropriate buffer; the source is not changed (“yank” or “copy”)
C
Changes to the end of the current line. = c$
D
Deletes to the end of the current line. = d$
x
Deletes the current character. This is equivalent to the dl command.
Y
Yanks the current line. This is equivalent to the yy command.
1dd
Delete the current line
1yy
Copy (yank) the current line
:%s/old/new/g Change all occurrences of ‘old’ to ‘new’
Miscellaneous Commands:
J
Joins count lines together. ('i' enter to split line)
P p
Paste buffer contents after the cursor. ('p' puts text before the cursor.)
u U Undoes last/all change. If repeated, you undo the undo
ZZ
Writes the file out, if changed, and then exits.
.
Repeats the last command.
for s in $(ls *.jar); do echo $s; jar -tvf $s | grep xxxString; done
Search through jars for xxxString
Tips:
Use the escape key to leave insert, change or append mode and enter command mode.
Always use the cursor keys (→ ↑ ← ↓) to move around in the file. (Never use the mouse!)
11/27/2012
WSC Lab System Information
Page 8
IBM System z Wildfire Seminars – ZJAV1 – Java Exploiters
Re-Cloning the VM Guest
Connect to zVM at 9.82.24.186 (webgen.ws - I used ScreenSize=60x80)
•Logon to the clone's VM system, just as you do to IPL it (webgen3#), and logoff which kills it.
•Logon to the master (230) system, and go into $$GEN3.SETUP.CNTL and submit these jobs:
(All of the jobs run on the master start with MC so in SDSF you'll want to do PREFIX MC.)
•WSLINITx where x is the letter designation of the clone. (See list below.) After that runs
successfully, you submit
•WSLCOPYx. That will run 15 jobs. After all 15 have completed successfully (no return
codes > 4) submit …
•WSLLABLx.
•After that runs successfully, logoff of the master, and logon to VM for the respective clone
WEBGEN3x.
•Hit enter and you'll be prompted for how you want to proceed.
•Reply 'Y' to IPL.
•Reply 'R 00,CONTINUE' to this message: ILR031A REPLY 'DENY' TO PREVENT ACCESS,
'CONTINUE' TO ALLOW USE OF PAGE.WSLPGE.PLPA.
•Then just wait unit SOF finishes and you're done.
•Then hit the <PA1> key and type 'disc' to disconnect.
Re-IPLing the VM Guest:
•Login to 9.82.24.186 (webgen) as webgen3# (pw = webgen3#) where # = the alphabetic letter
corresponding to the last two digits of your ipaddress (see chart at the bottom of this note.)
•Hit the 'clear' key to go to the MVS console. (Do NOT Log Off or the VM guest will go away.)
•To IPL, hit <PA1>, and type '#cp i cms' and take all the defaults
•Reply "Y" to IPL with no Prompts.
•Type "R 0,I" when you see this message: IXC420D
OR R TO REINITIALIZE XCF.
REPLY I TO INITIALIZE SYSPLEX WSLPLEX,
REPLYING I WILL IMPACT OTHER ACTIVE SYSTEMS.
•Reply 'R 00,CONTINUE' to this message: ILR031A REPLY 'DENY' TO PREVENT ACCESS,
'CONTINUE' TO ALLOW USE OF PAGE.WSLPGE.PLPA.
•Wait for all IPL start-up messages to complete. ("SOF ENDED")
•Then hit the <PA1> key and type 'disc' to disconnect.
Team Numbers and VM Guest Machine Assignments:
•201 = a
•202 = b
•203 = c
•204 = d
•205 = e
•206 = f
•207 = g
•208 = h
•209 = i
•210 = j
11/27/2012
•211 = k
•212 = l ('el')
•213 = m
•214 = n
•215 = o
•216 = p
•217 = q
•218 = r
•219 = s
•220 = t
WSC Lab System Information
Page 9
WebSphere Batch V8.5 Configuration - Lab #2
Revision Date: November 06, 2012
These instructions assume that you have an ND Cell with two configured servers. The instructors
have already configured the following:
✔ Created WAS V8.5 Deployment Manager and Empty Node using the WCT-generated jobs.
✔ Created DB2 database & tables using the supplied DDL files.
✔ Defined EJBROLE and STARTED Class RACF profiles.
✔ Created Servers Z8DISP & Z8ENDP and coherent port #s.
(These steps are documented in more detail in “IBM Modern Batch - Feature Pack and
Compute Grid” at www.ibm.com/support/techdocs/atsmastr.nsf/WebIndex/WP101783 )
Note: See “Basic System Info” behind Lab #2 for more information as necessary.
A copy of the lab handouts are on your workstation in the WCG01 folder on your desktop.
(This may be helpful in copying text, such as URLs or command lines in these labs.)
This is a multiple-step process: (starting with an ND Cell containing two servers)
1. Create Data sources for Scheduler & Endpoint servers
2. Configure the Job Scheduler using the ISC.
3. Install a sample Batch Application which configures the Endpoint Server (ISC)
4. Validate the run-time using the ISC and Job Management Console ( JMC)
5. Install and run some sample batch applications.
Start up the Z8Cell Deployment Manager
 Log on to TSO as “user1” (pw = user1)
 Go to SDSF (type “SDSF” or “d” on the command line) and start (1) DB2, (2) the
Deployment Manager and (3) the Node Agent with these MVS commands. (Type a slash
“/” and click “enter” to get to the SDSF “System Command Extension” panel, where you
can enter these commands without a “/”.)
1. DB2:
-dsn9 start db2
2. Deployment Mgr: s z8dcr,jobname=z8dmgr,env=z8cell.z8dmnode.z8dmgr
3. Node agent:
s z8acra,jobname=z8agnta,env=z8cell.z8nodea.z8agnta
 When the Deployment Manager comes up (in about 2 - 3 minutes), point your browser to the
ISC (Administrative Console) at
http://wg31.washington.ibm.com:20005/ibm/console
 Log in with the administrator's UserID (“Z8ADMIN”)
 Set Console Preferences to “Synchronize changes with Nodes” in System administration,
and click on “Apply”.
11/27/2012
Unit 4 - Lab - Part 2 - WCGv85_Configuration.odt
1 of 14
Enabling Application Security
The Compute Grid Job Management Console requires Application security to be enabled if Global
Security is enabled.
 In the ISC, go to Security > Global Security, and check “Enable application security.”
 Click on “Apply” then click on “Save”
Creating the Data sources
 In the ISC, go to Resources > JDBC > Data sources and set the scope to “z8cell”.
Create the Dispatcher Data source
 Select “New”.
 Create a data source named “Dispatcher” with a jndi name of “jdbc/lrsched”.
 Step 2: Select “Create new JDBC provider”, and click “Next.”
 Step 2.1, select “DB2”, “DB2 Universal Driver Provider”, and “Connection pool data source”
as show in the following screen shot, and click “Next.”
11/27/2012
Unit 4 - Lab - Part 2 - WCGv85_Configuration.odt
2 of 14
 In Step 2.2, specify the following:
1. “/shared/db2910_jdbc/classes” as the Directory Location for the jar files, and
2. “/shared/db2910_jdbc/lib” as the Native library path (Directory location), as in the
following screen shot:
 Click “Next.”
 In step 3, specify Driver type “2”, and Database name “WG31DB2” (This is the DB2 Location
name.)
11/27/2012
Unit 4 - Lab - Part 2 - WCGv85_Configuration.odt
3 of 14
 Click “Next”, take the Defaults, and click “Next” again.
 Click “Finish” and verify the highlighted items:
Important: Carefully validate the following values, and ask an instructor for help if they don't
match!
 Click “Save” and synchronize the cell.
Create the Endpoint Data source
 Repeat this process for the Endpoint Data source, with a jndi name of “jdbc/pgc”.
 In Step 2, click on “Select an existing JDBC provider” and “DB2 Universal Driver Provider”
 Specify the same remaining properties as you did for the Dispatcher data source.
 Click “Finish” and then “Save”.
Create the Customer Data source
 While you are in the neighborhood, repeat this process for a “Customer Datasource”, with a
jndi name of “jdbc/CUSTdb”.
 Follow the same steps as you did for the “Endpoint” data source; Save and Synchronize.
Set the currentSchema Custom Properties
Set the “currentSchema” Custom property in the Dispatcher and Endpoint data sources to
“LRSSCHMA” as follows:
 Navigate to Resources > Data sources > Dispatcher > Custom properties and set
“currentSchema” Custom property to “LRSSCHMA”.
 Navigate to Resources > Data sources > Endpoint > Custom properties and set
“currentSchema” Custom property to “LRSSCHMA”.
 Click “Save” and Synchronize your changes .
 Navigate to Resources > JDBC > Data sources (All scopes). You should see these three:
11/27/2012
Unit 4 - Lab - Part 2 - WCGv85_Configuration.odt
4 of 14
Configuring the Job Scheduler
 Click on “System Administration” > “Job Scheduler”
 Set the following fields as shown in the illustration below:
1.
“Scheduler hosted by” server z8dispa
2.
Change “Database schema name” from “LRSSCHEMA” to “LRSSCHMA”
3.
4.
Leave the “Data source JNDI name” as “jdbc/lrsched”.
Leave the “Endpoint job log location” set to the default location.
 Verify the “Scheduler hosted by” z8dispa, and the “Database schema name” is
LRSSCHMA.
 Click “OK” and save / synchronize.
Configuring the Endpoint Server
Install a batch application into the Endpoint server “z8endpa”. This designates that server as an
endpoint and the Deployment manager does the rest. We copied the sample “SimpleCI.zip” file
from the “Samples, Version 8.5” InfoCenter to the C:\ComputeGrid\ directory and extracted it.
 Navigate in the ISC to ”Applications” > “New Application” > “New Enterprise Application” and
select “Local file system” and click “Choose File”.
 In “Choose File”, select
C:\ComputeGrid\sample_simpleci\sample_simpleci\SimpleCI\installableApps\SimpleCI.ear
11/27/2012
Unit 4 - Lab - Part 2 - WCGv85_Configuration.odt
5 of 14
 Select “Next”, then select “Fast Path - Prompt only when additional information is required.”
 Step 1: Take all the defaults, and click “Next”.
 Step 2: Map the application to the endpoint server (z8endpa): (1) Click on the z8endpa
server, (2) check the “Select” box, and (3) click the “Apply” button.
 Verify that the server selected is “z8endpa”, and click on “Next”, “Finish”, “Save” and
synchronize your changes.
Now verify the Job scheduler configuration:
 Go to System Administration > Job scheduler.
 Click on "WebSphere grid endpoints":
Which will bring up this panel:
11/27/2012
Unit 4 - Lab - Part 2 - WCGv85_Configuration.odt
6 of 14
Verify the following in the “WebSphere grid endpoints” panel (as shown above):
 The “Name” column should contain the endpoint server where you just installed the Batch
Application (cell=z8cell,node=z8nodea,server=z8endpa).
Note: If the Endpoint name in the above panel shows up as “server=z8dispa” then
Uninstall the application and re-Install the SimpleCI application, choosing
“server=z8endpa”.
 The “Datasource JNDI Name” should match Endpoint Datasource setting. (jdbc/pgc)
 Logout of the ISC.
 Stop the Deployment Manager.
 Go back to TSO / SDSF, and type “PRE Z8” on the Command line to set the PREfix.
 Use the 'Y' action character on the SDSF DA panel.)
SDSF DA WG31
WG31
COMMAND INPUT ===>
PREFIX=Z8* DEST=(ALL)
NP
JOBNAME StepName
Z8AGNTA Z8AGNTA
Z8DEMN
Z8DEMN
Y
Z8DMGR
Z8DMGR
Z8DMGRS Z8DMGRS
PAG 41
OWNER=*
JobID
STC00039
STC00038
STC00042
STC00043
CPU
87
LINE 1-8 (8)
SCROLL
SORT=JOBNAME/A SYSNAME=
CPU% Real Paging
SIO ASID ASIDX
0.13 65T
0.00
0.00
63 003F
0.00 301
0.00
0.00
15 000F
0.13 77T
0.00
0.00
65 0041
0.13 106T
0.00
0.00
66 0042
 Re-start the Deployment Manager using the command you used on page 1 of these
instructions.
 Log back into the ISC, and start your two servers by going to “Servers” > “Server Types” >
“WebSphere application servers” selecting the servers and clicking “Start”:
11/27/2012
Unit 4 - Lab - Part 2 - WCGv85_Configuration.odt
7 of 14
 Go to the SDSF DA (display active) panel and watch the servers come up:
SDSF DA WG31
WG31
COMMAND INPUT ===>
PREFIX=Z8* DEST=(ALL)
NP
JOBNAME StepName
Z8AGNTA Z8AGNTA
Z8DEMN
Z8DEMN
Z8DISPA Z8DISPA
Z8DISPAS Z8DISPAS
Z8DMGR
Z8DMGR
Z8DMGRS Z8DMGRS
Z8ENDPA Z8ENDPA
Z8ENDPAS Z8ENDPAS
PAG 41
OWNER=*
JobID
STC00039
STC00038
STC00044
STC00045
STC00042
STC00043
STC00046
STC00047
CPU
87
LINE 1-8 (8)
SCROLL
SORT=JOBNAME/A SYSNAME=
CPU% Real Paging
SIO ASID ASIDX
0.13 65T
0.00
0.00
63 003F
0.00 301
0.00
0.00
15 000F
0.27 85T
0.00
0.00
67 0043
0.13 107T
0.00
0.00
68 0044
0.13 77T
0.00
0.00
65 0041
0.13 106T
0.00
0.00
66 0042
0.13 71T
0.00
0.00
69 0045
84.45 92T
0.00 14349
70 0046
Validating the Compute Grid Configuration
Now that you've configured the dispatcher and endpoints you're
ready to submit jobs and run batch applications.
Running the sample "SimpleCI" application
This application is already installed. (Remember; you used it to designate the
endpoint server as an “Endpoint” to the Job Scheduler.)
 Make sure the SimpleCI application is up and running:
 Point your browser at the JMC in the dispatcher server:




http://wg31.washington.ibm.com:20067/jmc
You should now be prompted for a userid and password. Your WAS administrator's ID
“z8admin” has access to the EJBROLEs of Z8CELL.lradmin and
Z8CELL.lrsubmitter, so that should be good to log onto the JMC.
Click “Submit a job”
Use the “Choose File” button to select the SimpleCIxJCL.xml file that we copied from the
Samples, Version 8.5 InfoCenter to the following directory on your workstation:
C:\ComputeGrid\sample_simpleci\sample_simpleci\SimpleCI\scripts\
Check the “Update substitution properties” box, and click on “Submit,” as seen in the
following picture:
11/27/2012
Unit 4 - Lab - Part 2 - WCGv85_Configuration.odt
8 of 14
 The next screen to pop up is the Substitution properties:
 Change the “outfile” property to “/tmp/simpleciout.txt: and click “Submit.”
 You should see the following message:
11/27/2012
Unit 4 - Lab - Part 2 - WCGv85_Configuration.odt
9 of 14
 Now click on "View jobs". This will take you to a listing of all the jobs seen in the dispatcher
database. Depending on how quickly you clicked on "View jobs" you'll see the state of
the job as either Submitted, Executing or Ended. For example:
 The little twisty-arrow icon next to "State" will refresh the job state values. Use that periodically
until your job goes to a state of "Ended."
 Now explore a bit: Notice how the job has a number appended to it. WCG keeps track of the jobs
submitted and appends the number to make each unique. Click on the job ID link to open up
a view of the job log.
Notes:
1. Review the joblog: it contains the submitted xJCL and then the xJCL with all substitution
properties updated. Down at the bottom it tells you which endpoint the job was dispatched to.
2. Note how the job log will be offered in multiple pages. Clicking on the arrow icon to go to the
second page yields the output from the execution of SimpleCI, and the final status.
3. The "Download" button provides a means of downloading the joblog as a zip file to your
workstation.
4. The "Select Action" pull-down offers a set of actions that you may apply to a selected job in
the list. For a job in state "Ended" the only action that's applicable is "Remove." That will
remove the job information from the database and erase the job logs as well.
11/27/2012
Unit 4 - Lab - Part 2 - WCGv85_Configuration.odt
10 of 14
 (Optional) Re-submit the SimpleCIxJCL.xml file and check the "Update substitution
properties", click “Submit” and change the “calctime” value from 30 to some other
number.
 Then click “OK”. The job will run for your new specified amount of time.
Congratulations -- you have validated your WebSphere Compute Grid environment.
11/27/2012
Unit 4 - Lab - Part 2 - WCGv85_Configuration.odt
11 of 14
Sample application "XDCGIVT"
This sample application is useful because it exercises WCG functions not used by the SimpleCI:
Multiple job steps, read & write operations, and the checkpoint algorithm.
This application uses a DB2 table as one of it's options. As mentioned before, it is possible to
bypass DB2 with this application, but it's more meaningful to show its use.
Recommendation: When first setting up your environment, follow the instructions we provide here
fairly carefully. In particular, use the default names for schema and JNDI names. That will allow the
sample xJCL to line up nicely with a minimum of changes. Later, when you get more comfortable with
the interrelationships you may experiment with your own names.
We have already created the DB2 table for the IVT table. (The ddl is provided in the Samples,
Version 8.5 InfoCenter which we downloaded to your workstation in the
C:\ComputeGrid\sample_ivt\sample_ivt\IVT\scripts\CreateIVTTablesDB2.ddl file.)
 Create a JDBC datasource under the existing JDBC provider:
 In the ISC, go to “Resources” > “JDBC” > “Data sources”. Set the scope to Cell=z8cell, and
click on “New”
 Specify any name such as 'IVT data source'
 Specify a JNDI name of jdbc/IVTdb, and click “Next”
 Use the existing JDBC provider “DB2 Universal JDBC Provider” and click “Next”.
 Step 3: specify Type 2 driver, and the DB2 Location name “WG31DB2” for the
Database name, and click “Next”.
 Take the remaining defaults, and click on “Finish.”
 Select (click on) the IVT Data source under “data sources.”
 Click on “custom properties”, find and click on “currentSchema”
 Specify “Z8IVTSC” in the “Value” field.
 Click “OK”, Save and synchronize.
 Restart the Endpoint server “Z8ENDPA” for these changes to be picked up: In the ISC,
go to “Servers” > “Server Types” > “WebSphere application servers” selecting the
z8endpa server and clicking “Restart”.
11/27/2012
Unit 4 - Lab - Part 2 - WCGv85_Configuration.odt
12 of 14
Install the XDCGIVT.ear application
 Install it from the “Local file system” (your workstation) in this directory:
C:\ComputeGrid\sample_ivt\sample_ivt\IVT\installableApps
 Click on the “Detailed” path to “Show all installation options and parameters.”
 Click “Next”.
 Click “Continue”
 Step 1: Click “Next”
 Step 2: Select the endpoint server: (1) Click on the z8endpa server, (2) check the
“Select” box, and (3) click the “Apply” button.
 Make sure the z8endpa server is selected!
 Click “Next”.
 Step 3: Set the Database type to be “DB2UDBOS390_V9” and schema to “Z8IVTSC”.
 Steps 4 - 10: Take the remaining defaults, and click “Finish” and “Save.”
 Start the application.
Submit the xJCL for the XDCGIVT
 We have copied the XDCGIVTtxt2db2txtxJCL.xml from the Samples, V 8.5
InfoCenter to the C:\ComputeGrid\sample_ivt\sample_ivt\IVT\scripts
folder on your workstation.
 Go to the JMC to submit the xJCL job from the Local file you just saved:
11/27/2012
Unit 4 - Lab - Part 2 - WCGv85_Configuration.odt
13 of 14
 Click on “Choose File”, then specify the following xJCL file:
C:\ComputeGrid\sample_ivt\sample_ivt\IVT\scripts\XDCGIVTtxt2db2txtxJCL.xml
 Check the "Update substitution properties", and click “Submit”:
 Change the following Property values:
DB2info = Z8IVTSC.IVTTABLE
DB2jndi = jdbc/IVTdb
inputDatastream = /tmp/input.txt
outputDatastream = /tmp/output.txt
 Click “Submit" and watch for it to go through "Submitted" to "Executing" to "Ended."
 Browse the job log by clicking on the link for the finished job.
 Go beyond the 1st page to see the messages issued by the Endpoint server.
11/27/2012
Unit 4 - Lab - Part 2 - WCGv85_Configuration.odt
14 of 14
IBM System z Wildfire Seminars – ZJAV1 – Java Exploiters
LAB 4C:
WEBSPHERE BATCH PROGRAMMING
COMPUTE-INTENSIVE APPLICATION
Last Updated: 2012-10-30
Lab Objective
The objective of this lab is to provide a basic understanding of IBM® WebSphere Batch programming.
We will look at three different scenarios:
•
•
•
Compute-intensive application
Single step transactional batch application
Multi-step transactional batch application
Pre-requisites
 IBM® Rational® Application Developer for WebSphere® Software V8.0.1 (RAD)
 Compute Grid Tools for Modern Batch feature
 IBM® WebSphere® Application Server Version 7.0 Test Environment (7.0.0.13)
 Feature Pack for Modern Batch
On our workstations, we are using RAD 8.5 + WAS 8.5.
In this lab, many of the steps require that the previous steps be completed. To help ensure that you do
not mistakenly skip a step, we encourage you to utilize the checkboxes (□) next to each step. Please
check off each step (☑) as you complete it.
Lab Trivia
This lab uses a compute-intensive batch application that calculates the approximate value of 𝜋 using a
formula developed by John Machin in 1706. Using this formula, he became the first person to correctly
calculate the first 100 digits of 𝜋.
The formula is
𝜋
4
1
1
= 4 arctan 5 − arctan 239.
We calculate the arctangent using the infinite series: arctan 𝑧 = 𝑧 −
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
𝑧3
3
+
𝑧5
5
−
𝑧7
7
∙∙∙
Page 2 of 28
©2012 IBM Corporation
□ 01. On your Windows desktop, double-click on the icon for Rational Application Developer.
Do not click on the icon for IBM Rational Developer for System z.
□ 02. When prompted for the location of the workspace, enter:
c:\ComputeGrid\workspaces\wcg01
Click OK.
□ 03. Make sure you are in the Java EE perspective.
Above the Outline pane (upper right), click the Open Perspective icon and select Other…
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 3 of 28
©2012 IBM Corporation
□ 04. Select Java EE.
Click OK.
□ 05. You'll notice the CalculatePi Java project in your workspace. This is a standalone Java application.
Expand CalculatePi → src → com.ibm.wsc.
CalculatePi.java is a standalone application (Java “main” class).
□ 06. Before converting this into a compute-intensive application, we will run this application in RAD.
Right-click on CalculatePi.java in the enterprise explorer.
Select Run As → Run Configurations…
The screenshot below has been altered for sizing purposes. The location of the menu items will
be different on your workstation.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 4 of 28
©2012 IBM Corporation
□ 07. Right-click on Java Application.
Select New.
□ 08. You should see the Run Configurations window. Click on the Arguments tab.
□ 09. The CalculatePi application takes a command line argument. This argument tells the application
how many digits of pi to calculate.
For Program arguments, enter 50. This will tell CalculatePi to calculate the first 50 digits of pi.
Note:
CalculatePi artificially limits the maximum number of digits to 200. That is, you cannot
ask the application to calculate more than 200 digits of pi.
□ 10. Click the Run button at the bottom of the Run Configurations window.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 5 of 28
©2012 IBM Corporation
□ 11. In the Console tab, you should see the results of the application.
□ 12. Now that we have seen how this standalone application works, we will turn this into a WCG
compute-intensive application.
We have already created a project for you called CalculatePiBatch.
Now we will create the job step class that implements the CIWork interface. In the enterprise
explorer, expand CalculatePiBatch → src.
Right-click on com.ibm.wsc. Select New  Class.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 6 of 28
©2012 IBM Corporation
□ 13. Ensure that the Source folder is CalculatePiBatch/src and the package is com.ibm.wsc.
In the Name textbox, enter CalculatePi.
Next to the Interfaces textbox, click on the Add… button.
□ 14. This class will be the primary class for the compute-intensive batch job. It must implement the
com.ibm.websphere.ci.CIWork interface in order for the batch job to operate correctly.
In the Choose Interfaces textbox, enter com.ibm.websphere.ci.ciwork.
CIWork should appear in the Matching items box.
Click OK.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 7 of 28
©2012 IBM Corporation
□ 15. The CIWork interface should appear in the interfaces box.
Click Finish.
□ 16. In the enterprise explorer, expand CalculatePiBatch → src → com.ibm.wsc.
Double-click on CalculatePi.java. The source should open.
□ 17. Now we need to write a few lines of code.
Find this line of code (it should be close to the top):
Underneath this, you will type this line:
java.util.Map<String,String> props = null;
private static boolean cancelJob = false;
The code should now look like this:
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 8 of 28
©2012 IBM Corporation
Hint:
These lines of code are also located at C:\ComputeGrid\lab4a.txt. You can
copy/paste from there.
This will declare a Map object, which will contain properties that will be passed from the xJCL.
This will also declare a boolean variable that is monitored by the run() method in case your job
is cancelled.
□ 18. Find the getProperties() method.
It will look similar to this.
Instead of returning null, we want this method to return the Map object containing our
properties.
Replace
return null;
with
return this.props;
The method should now look like this.
What did
I just do?
You altered the getProperties() method so it will return any properties that
may have been specified by the xJCL.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 9 of 28
©2012 IBM Corporation
□ 19. Find the setProperties() method.
It will look similar to this.
Underneath the // TODO comment, add this line.
this.props = arg0;
The method should now look like this:
What did
I just do?
The setProperties() method is called by the CIControllerBean in order to pass
in any properties that have been specified by the xJCL.
We changed this method so it will populate our Map object (props) with any of the
aforementioned properties.
□ 20. Click on the disk icon below the menu bar (in the upper left) to save your changes. You can also
press CTRL-s to save.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 10 of 28
©2012 IBM Corporation
□ 21. Now we are ready to copy and paste from the original standalone CalculatePi.java.
In the enterprise explorer, expand CalculatePi → src → com.ibm.wsc.
Double-click on CalculatePi.java.
□ 22. Inside CalculatePi.java, look for the main method:
□ 23. Mark all code between the brackets { }. You can do this by clicking and dragging your mouse.
You'll start with this line:
You'll end with this line:
There are comments in the code to guide you. For example:
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 11 of 28
©2012 IBM Corporation
□ 24. Once the code has been marked, it should look highlighted:
□ 25. In the menu bar, click on Edit → Copy.
□ 26. Close CalculatePi.java by clicking on the X next to it.
□ 27. In the enterprise explorer, expand CalculatePiBatch → src → com.ibm.wsc.
Double-click on CalculatePi.java. This is where we will paste the code we just copied.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 12 of 28
©2012 IBM Corporation
□ 28. Find the run() method. It will be toward the bottom.
□ 29. Click inside the brackets { } of the run() method.
In the menu bar, click Edit → Paste.
□ 30. Now we need to modify the code.
Find and remove these lines of code:
What did
I just do?
These lines of code parse through the command-line argument. They are used
when running the standalone version of CalculatePi.
We no longer need to do this since we will be using a property in the xJCL.
□ 31. Uncomment these lines of code. You can do this by deleting the lines in the red boxes.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 13 of 28
©2012 IBM Corporation
These lines of code will read the value of a property in order to determine how many digits of pi
to calculate. This property is set in the xJCL.
□ 32. Find the isDaemon() method.
□ 33. Change the line
return false;
to
return true;
What did
I just do?
The isDaemon() method must return true for compute-intensive jobs. This tells
the batch container that your job will run for an extended period of time.
□ 34. Find the release() method.
□ 35. Add this line of code to release():
cancelJob = true;
What did
I just do?
The release() method is called on a separate thread when the job is cancelled.
The cancelJob variable will be used to tell the run() method to end gracefully.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 14 of 28
©2012 IBM Corporation
□ 36. Click on the disk icon below the menu bar to save your changes. You can also press CTRL-s to
save.
□ 37. Close the source to CalculatePi.java by clicking on the X next to it.
□ 38. We need to copy another method from our standalone Java program.
In the enterprise explorer, expand CalculatePi  src  com.ibm.wsc.
Double-click on CalculatePi.java.
□ 39. Find the calculateArctangent() method.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 15 of 28
©2012 IBM Corporation
□ 40. Copy the entire method. You can do this by clicking and dragging your mouse to mark the code.
□ 41. In the menu bar, click on Edit → Copy.
□ 42. Close CalculatePi.java by clicking on the X next to it.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 16 of 28
©2012 IBM Corporation
□ 43. In the enterprise explorer, expand CalculatePiBatch → src → com.ibm.wsc.
Double-click on CalculatePi.java. This is where we will paste the code we just copied.
□ 44. Find the run() method.
□ 45. We will paste the calculateArctangent() method above the run() method.
□ 46. In the menu bar, click Edit → Paste.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 17 of 28
©2012 IBM Corporation
□ 47. Click on the disk icon below the menu bar to save your changes. You can also press CTRL-s to
save.
□ 48. Our batch job allows us to set a property, which will let us pass in a parameter specifying the
number of digits of pi to calculate. We need to set this property in the xJCL.
In the enterprise explorer, expand CalculatePiBatch → xJCL.
Double-click on CalculatePiBatch.xml.
□ 49. In the xJCL editor, click on CalculatePiBatch.
Click the Add… button.
□ 50. Select Substitution Properties.
Click the OK button.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 18 of 28
©2012 IBM Corporation
□ 51. In the Substitution Properties wizard, click Add...
□ 52. Enter digitsToCalculate as the property key.
Click OK.
□ 53. Across from the digitsToCalculate key, double-click in the Value column.
Enter 100. We can change this dynamically when submitting the xJCL, but we will use 100 as the
default value.
Click Finish.
□ 54. In the xJCL editor, click on CalculatePiBatch.
Click on Add…
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 19 of 28
©2012 IBM Corporation
□ 55. Select Job Step.
Click OK.
□ 56. For Name, enter step1.
In the Select Pattern dropdown box, select CI Work.
□ 57. Click Browse next to Implementation Class.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 20 of 28
©2012 IBM Corporation
□ 58. In the Type Selection window, type CalculatePi.
Select CalculatePi from Matching items.
Click OK.
□ 59. In the xJCL editor, expand Job (CalculatePiBatch).
Click on Job Step (Step1).
Click on Add…
□ 60. In the Add Item window, click Properties.
Click OK.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 21 of 28
©2012 IBM Corporation
□ 61. In the xJCL editor, click on Property ().
□ 62. In the Details section, enter digitsToCalculate for the name.
Enter ${digitsToCalculate} as the value. This will use the substitution property, which we created
above, as the value.
□ 63. Click on the disk icon below the menu bar to save your changes. You can also press CTRL-s to
save.
□ 64. We are now ready to deploy our CI application.
Right-click on CalculatePiBatchEAR.
Select Export → EAR file.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 22 of 28
©2012 IBM Corporation
□ 65. In the Export window, ensure that the EAR project is set to CalculatePiBatchEAR.
For the Destination, enter c:\ComputeGrid\export\CalculatePiBatch.ear.
Check the boxes for Overwrite existing file and Export source files.
Click Finish.
□ 66. Log into the ISC and deploy your application.
Since you have already deployed applications in previous labs, we will not enumerate the steps
required.
The URL for the ISC is http://wg31:20005/admin
Remember to deploy the application to the endpoint server: z8endpa.
When the deployment process is complete, start your application.
□ 67. We are ready to submit our CI job.
Log into the JMC: http://wg31:20067/jmc
Under Job Management, click on Submit a job.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 23 of 28
©2012 IBM Corporation
□ 68. In the right pane of the JMC, click on the radio button for Local file system.
Click the Choose file or Browse button (this will depend on what browser you are using).
Navigate to c:\ComputeGrid\workspaces\wcg01\CalculatePiBatch\xJCL.
Select CalculatePiBatch.xml.
Click Submit.
□ 69. You should see a message indicating your job was submitted.
What is your job ID?
__________________________________________________
In the above example, the job ID is CalcuatePiBatch:00049.
□ 70. In the left pane of the JMC, click on View jobs.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 24 of 28
©2012 IBM Corporation
□ 71. Find your job ID in the list of submitted jobs.
Ensure that your job's state is Ended.
If it is still in the Running state, click on the circular arrows next to State in order to refresh. The
job should not take longer than a few minutes to complete.
□ 72. When your job has ended, click on the link for your job.
□ 73. Go to page two of the job log.
You should see the output from the CalculatePiBatch job.
□ 74. Congratulations! You have successfully executed a CI application.
□ 75. Submit your job again. This time, click on the checkbox for Update substitution properties and
enter a different value for the number of digits of pi to calculate.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 25 of 28
©2012 IBM Corporation
□ 76. Check your job log to see your batch job calculated the correct amount of digits.
□ 77. Submit your job again. This time, click on the checkbox for Update substitution properties and
enter a value of 200.
□ 78. Look in the job log for your submitted job. How long did it take to execute?
In the above example, it took over three minutes.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 26 of 28
©2012 IBM Corporation
□ 79. Now we will cancel the job while it is executing.
Submit the job again. Use a value of 200 for digits to calculate. This will ensure we have enough
time to cancel the job while the job is executing.
What is the job ID?
_____________________________________________
In the above example, the job ID is CalculatePiBatch:00007.
□ 80. In the left pane of the JMC, click on View jobs.
□ 81. You should see your job in the Executing state.
□ 82. Check the box next to you job and select Cancel from the dropdown box.
Click Apply.
□ 83. You can click on the circular arrows next to State to refresh.
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 27 of 28
©2012 IBM Corporation
□ 84. You should see your job in a Restartable state.
□ 85. Congratulations! You have completed this lab!
WebSphere Batch for z/OS Workshop
Lab 4c: WebSphere Batch Programming Models -- CI
Last Updated: 2012-10-30
Page 28 of 28
©2012 IBM Corporation
IBM System z Wildfire Seminars
z/OS Java Exploiters and Java Batch
Unit 5: Shared Class Data Cache
Last updated: 2012-01-27
© 2012 IBM Corporation
Why Use a Cache?
 Not used for inter-JVM communcation
 Used to decrease storage needed by JVM
 Used to decrease startup and application loading times
 No application changes needed
© 2012 IBM Corporation
IBM Americas Advanced Technical Skills
IBM Amercas – Advanced Technical Skills
2
1
Shared Classes
A function of SDK 5+ that allows one or more JVM instances to store in a
separate cache
 This is a function of the JVM. Transparent to the
application.
JVM
Ca
Cb
JVM
Cy
 The shared cache is a separate allocation of memory,
apart from the JVM
Shared Cache
C1
C3
C2
Cn
 When a JVM is created, it can be told to create a shared
cache or connect to an existing one
 If connected to a cache, the JVM will first look in the
cache for a class. If there, it’ll read from there. If not,
it’ll load from the HFS and then store in the cache.
Cz
 All bootstrap classes shared
 Cache and JIT? In SDK 6.0.1, cache can store JITed
code; prior to 6.0.1, no JITed code in cache
 Cache persisted beyond lifetime of any JVM, but lost on
IPL
Additional parameters to JVM:
-Xscmx25m -Xshareclasses:name=MyCache
Command to display shared caches:
Benefits:
ipcs -bom
 Faster class access = performance
 Smaller JVM footprint
http://www.redbooks.ibm.com/redbooks/pdfs/sg247291.pdf
© 2012 IBM Corporation
IBM Amercas – Advanced Technical Skills
3
Shared Class Cache Lifecycle
1
java -Xshareclasses:name=MyCache HelloWorld
JVM
HelloWorld
Shared Cache
C1
Cn
 JVM creates new cache named MyCache
 HelloWorld is loaded into MyCache
HelloWorld
2
java -Xshareclasses:name=MyCache GoodbyeWorld
JVM
GoodbyeWorld
Shared Cache
C1
Cn
 Other JVMs can connect to MyCache
 They can load other classes or use already loaded
classes (like bootstrap classes)
HelloWorld
GoodbyeWorld
© 2012 IBM Corporation
IBM Americas Advanced Technical Skills
IBM Amercas – Advanced Technical Skills
4
2
Shared Class Cache Lifecycle
Look in lab instructions
for details on
3
java -Xshareclasses:name=MyCache,printStats
Current statistics…
Shared Cache
C1
printStats output
 Displays information on MyCache, including how
full the cache is and how many classes it contains
Cn
 printStats is considered a utility and no JVM is
instantiated
HelloWorld
 listAllCaches will display all available caches
GoodbyeWorld
4
java -Xshareclasses:name=MyCache HelloWorld
HFS
HelloWorld
4a
 If the class (or jar) has changed on the
file system, the cache is updated
dynamically
Shared Cache
4b
C1
JVM
4d
Cn
4c
 Jar files are locked during use; only
updated once the JVM shuts down
HelloWorld
HelloWorld
 .class files can be updated at any time
GoodbyeWorld
 Classes can be marked as “stale”
IBM Amercas – Advanced Technical Skills
© 2012 IBM Corporation
5
Shared Class Cache Lifecycle
5
 Only works if no JVMs are connected and user
has sufficient permission
java -Xshareclasses:name=MyCache,destroy
 destroyAll option will attempt to destroy all class
caches
Shared Cache
C1
 reset option will destroy and recreate a pristine
cache
Cn
 expire=<minutes> option will remove unused
caches
HelloWorld
(expire=0 same as destroyAll)
GoodbyeWorld
java -Xshareclasses:name=MyCache,groupAccess HelloWorld
Shared Class Cache Security
zeam01
Shared Cache
C1
Cn
HelloWorld
zeam02
© 2012 IBM Corporation
IBM Americas Advanced Technical Skills
GoodbyeWorld
 Be default, user level access is implemented
 Use groupAccess command to grant permission
to an entire group
 No matter what access level, a cache can only be
destroyed by the user that created it or a
superuser
IBM Amercas – Advanced Technical Skills
6
3
Cache Performance Improvements in 6.0.1
 Caching JIT data
– JVM can store JITed code in cache
– Enables subsequent JVMs to start and/or run faster
– If class in cache becomes stale, JIT data also becomes stale
– -Xshareclasses:nojitdata
(prevent JVM from caching JIT data)
– -Xscmaxjitdata<size>
(maximum cache space for JIT data)
– -Xscminjitdata<size>
(minimum cache space for JIT data)
• If not set, no space is set aside for JIT data; but JIT data is still written
to cache until full or –Xscmaxjitdata is reached
 Class Debug Area
– Cache stores class metadata (LineNumberTable &
LocalVariableTable); used for stacktraces and debugging
– -Xscdmx<size>
(maximum cache space for debug area)
– -Xnolinenumbers
(disable debug area in cache)
© 2012 IBM Corporation
IBM Amercas – Advanced Technical Skills
7
Ahead-Of-Time Compilation
 AOT compilation allows compilation of Java classes into native
code
 Subsequent JVMs can use AOT code to provide native code
without compilation
– Thus decreasing startup time
 Use -Xshareclasses:noaot, -Xscminaot, -Xscmaxaot to control
AOT code in cache
– Prevents JVM from storing AOT code in cache, places lower and
upper limit on space allocated for AOT code
© 2012 IBM Corporation
IBM Americas Advanced Technical Skills
IBM Amercas – Advanced Technical Skills
8
4
Cache Access
 JVMs can use a cache with read-write or readonly access
– Default is read-write
– Use –Xshareclasses:name=mycache,readonly
 Read-only access prevents classes from being updated in the
cache
 Read-only is slightly faster because no file locking is required
 Cannot create a cache readonly; can only use a cache readonly
Cache Compatibility
 Using the same cache with different service releases is not
recommended (may cause class duplication in cache)
 JVMs will destroy/recreate cache if created at a different SR
– May not succeed if cache is in use
9
IBM Amercas – Advanced Technical Skills
© 2012 IBM Corporation
Cache Sizing & Restrictions
 Maximum theoretical size of the cache is 2GB (for 31-bit JVMs)
– Default: 16mb
– Use –Xscmx<#>[k|m|g] (e.g., -Xscmx256m) to specify size
 How to keep users restricted?
– Cache lives in UNIX shared memory segment (resides in
extended system queue area [ESQA])
– Limiting shared memory segment size in BPXPRMxx:
IPCSHMMPAGES setting
– Use /d omvs,o in SDSF to check current settings
Max # of pages for
shared memory
segments
Default: 25600
Shared page size for Java on z/OS:
31-bit: 4kb
64-bit: 1mb
Default cache size: 16mb
What’s the minimum size for IPCSHMMPAGES to
support 16mb cache on 31 bit?
𝒙 × 4kb page size = 16mb
A: 4096
© 2012 IBM Corporation
IBM Americas Advanced Technical Skills
IBM Amercas – Advanced Technical Skills
10
5
Miscellaneous Notes
 JVM will fill all cache with all class dependencies
– Subject to space restrictions
 Display entire contents of cache
java –Xshareclasses:name=AllZeams,printAllStats
– Capturing output to a file
java –Xshareclasses:name=AllZeams,printAllStats 2>&1 | tee /tmp/cachecontents
 Concurrent access – any # of JVMs can read/update a cache
simultaneously (but a JVM can only connect to a single cache)
 Utilities do not start the JVM; this is not an error:
Could not create the Java Virtual Machine
 Cache names are case sensitive: zeam01 vs Zeam01 vs ZEAM01
© 2012 IBM Corporation
IBM Amercas – Advanced Technical Skills
11
Lab 5: Shared Class Cache Lab
• Change environment to use Java 6 and 7
• Java 5 would also work
• Create a cache
• Look at the cache statistics
• Use the cache
• Destroy the cache
© 2012 IBM Corporation
IBM Americas Advanced Technical Skills
IBM Amercas – Advanced Technical Skills
6
The End
© 2012 IBM Corporation
IBM Americas Advanced Technical Skills
IBM Amercas – Advanced Technical Skills
13
7
IBM System z Wildfire Seminars – ZJAV1 – Java Exploiters
LAB 5: SHARED CLASS CACHE FOR JAVA ON Z/OS
Last updated: 2012-04-19
OVERVIEW
The purpose of this exercise is to illustrate the use of the shared class cache in Java on z/OS. Class data
sharing allows multiple JVMs to share a single space in memory. This reduces the overall virtual
memory consumption when more than one JVM shares a cache. Sharing also reduces the startup time
for a JVM after a cache has been created.
LAB REQUIREMENTS
 Java 6: This lab will also work with Java 5.
 UNIX® System Services: Please use your preferred method of accessing UNIX® System Services
(hereafter referred to as USS). You can go through OMVS (option 6 in TSO). Alternatively, you can
use a telnet client such as TeraTerm or Putty. Both utilities are provided on your workstation. Let
an instructor know if you need help.
 Sample Java programs: The source code for two Java programs, HelloWorld and GoodbyeWorld,
are found inside the /u/zeam01/cachelab. These are extremely simple programs that do nothing
print the text “Hello World!” and “Goodbye World!” to standard out.
LAB STEPS
PART 1: COMPILING THE SAMPLE JAVA PROGRAMS
You will copy the source code to your home directory and compile them.
PART 2: SIMULATING THE LIFECYCLE OF A CLASS DATA SHARING CACHE
You will create a class data sharing cache and populate it with the classes from Part 1. You will
modify the source and recompile. You will execute the program again, causing the modified
class to be loaded in the cache. You will test the security of the cache. Then the cache will be
destroyed.
z/OS Java Exploiters and Java Batch
Lab 5: Java Shared Class Cache
Last Updated: 2012-04-19
Page 2 of 8
©2012 IBM Corporation
PART 1: COMPILING THE SAMPLE JAVA PROGRAMS
□ 01. Logon to USS using ZEAM01.
Note:
You can use OMVS (option 6 in TSO) or a telnet client like TeraTerm or Putty. Both
TeraTerm and Putty have icons on the desktop.
Let an instructor know if you need help accessing USS.
□ 02. From an OMVS command prompt (or from the USS shell), modify your .profile so that Java 6
will be used instead of Java 5. This can be done by editing your .profile file, commenting out
the export JAVA_HOME statements that point to Java 5 and uncommenting the export
JAVA_HOME statement that points to Java 6.
For this lab, we will be using the 31-bit flavor of Java 6.
Note:
Exit and re-enter the USS shell after modifying your .profile so that the changes will
take effect.
□ 03. Test to make sure you are accessing Java 6 by using the java -version command. The version
returned should be 1.6.0.
> java –version
java version "1.6.0"
Java(TM) SE Runtime Environment (build pmz3160_26fp1-20110419_01)
IBM J9 VM (build 2.6, JRE 1.6.0 z/OS s390-31 20110418_80450 (JIT enabled, AOT enabled)
□ 04. Change directories to /u/zeam01/cachelab.
> cd /u/zeam01/cachelab
□ 05. Compile the programs.
> javac HelloWorld.java
> javac GoodbyeWorld.java
z/OS Java Exploiters and Java Batch
Lab 5: Java Shared Class Cache
Last Updated: 2012-04-19
Page 3 of 8
©2012 IBM Corporation
□ 06. Test the programs to ensure they run correctly.
> java HelloWorld
Hello World!
> java GoodbyeWorld
Goodbye World!
PART 2: SIMULATING THE LIFECYCLE OF A CLASS DATA SHARING CACHE
□ 01. Create a new cache by using the -Xshareclasses:name=zeam01 option and populate with
the HelloWorld program.
> java –Xshareclasses:name=zeam01 HelloWorld
Hello World!
z/OS Java Exploiters and Java Batch
Lab 5: Java Shared Class Cache
Last Updated: 2012-04-19
Page 4 of 8
©2012 IBM Corporation
□ 02. Use the printStats utility command to view some information on the cache. Interesting data
might include how full the cache is and how many classes the cache contains (ROMClasses).
> java –Xshareclasses:name=zeam01,printStats
Current statistics for cache "MyCache":
shared memory ID
= 270370
Cache created with:
-Xnolinenumbers
= false
base address
end address
allocation pointer
= 0x3E01C000
= 0x3F000000
= 0x3E111150
cache size
free bytes
ROMClass bytes
AOT bytes
JIT data bytes
Zip cache bytes
Data bytes
Metadata bytes
Metadata % used
Class debug area size
Class debug area used bytes
Class debug area % used
=
=
=
=
=
=
=
=
=
=
=
=
16776816
12670064
1003856
0
908
804576
114288
20436
1%
2162688
233036
10%
#
#
#
#
#
#
#
%
=
=
=
=
=
=
=
=
409
0
1
0
0
29
0
0%
ROMClasses
AOT Methods
Classpaths
URLs
Tokens
Zip caches
Stale classes
Stale classes
Cache is 13% full
The following table describes some of the above information.
z/OS Java Exploiters and Java Batch
Lab 5: Java Shared Class Cache
Last Updated: 2012-04-19
Page 5 of 8
©2012 IBM Corporation
cache size
Total size of the shared memory area in bytes
free size
Free bytes remaining
ROMClass bytes
Number of bytes of class data in the cache
AOT bytes
Number of bytes of Ahead Of Time compiled
code
Data bytes
Number of bytes of non-class data stored by
JVM
Metadata bytes
Number of bytes of data stored used to
describe cached classes
Metadata % used
Proportion of metadata bytes to class bytes
ROMClasses
Number of classes in the cache
Stale classes
Classes that have been marked as “potentially
stale”
□ 03. Add GoodbyeWorld to the cache using what you have learned above.
□ 04. Modify the HelloWorld source code (HelloWorld.java).
We just want to change the text in the System.out.println line.
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World, I’m back!");
}
}
Note:
You can use oedit to edit the source code. If you are using Putty or TeraTerm to access
USS directly, you can use vi.
□ 05. You will need to compile HelloWorld again.
> javac HelloWorld.java
z/OS Java Exploiters and Java Batch
Lab 5: Java Shared Class Cache
Last Updated: 2012-04-19
Page 6 of 8
©2012 IBM Corporation
□ 06. Execute the new HelloWorld. The JVM will load the new version into the cache.
> java –Xshareclasses:name=zeam01 HelloWorld
Hello World, I’m back!
□ 07. Does the shared class data cache make a difference, in terms of startup and execution time?
We can use the USS time command to take some rough measurements.
First, measure the time it takes to instantiate a JVM and run the HelloWorld program without
the shared class data cache.
> time java HelloWorld
Hello World, I’m back!
real
0m 4.02s
user
0m 0.43s
sys
0m 0.14s
The time command gives the results in total time to run (real), total time spent in the user
program (user), and total time spent in system processor overhead (sys).
Now let’s try it with the JVM accessing the cache.
> time java –Xshareclasses:name=zeam01 HelloWorld
Hello World, I’m back!
real
0m 2.85s
user
0m 0.27s
sys
0m 0.09s
Note:
This extremely simplified example is not meant to portray any real world performance
benefits. The actual performance benefits realized by using the shared class cache
depends on a number of variables.
□ 08. Use the listAllCaches utility function. This utility will list all available caches.
> java –Xshareclasses:listAllCaches
You should be able to see only your own.
z/OS Java Exploiters and Java Batch
Lab 5: Java Shared Class Cache
Last Updated: 2012-04-19
Page 7 of 8
©2012 IBM Corporation
□ 09. Your cache is ready to be destroyed. Use the destroy utility command to do so.
> java –Xshareclasses:name=zeam01,destroy
JVMSHRC010I Shared cache "zeam01" is destroyed
□ 10. We will now switch to Java 7 and use some of the new features for share class caches.
□ 11. Modify your .profile so that Java 7 will be used instead of Java 7. This can be done by editing
your .profile file, commenting out the export JAVA_HOME statements that point to Java 6 and
uncommenting the export JAVA_HOME statement that points to Java 7.
You can choose to use either the 31-bit or 64-bit version of Java 7.
Exit and re-enter USS so the changes to your .profile will take effect.
□ 12. Create a new cache with the name zeam01.
> java –Xshareclasses:name=zeam01 HelloWorld
□ 13. Print information about JIT data in the cache.
> java –Xshareclasses:name=zeam01,printStats=JITprofile
□ 14. Destroy your cache.
> java –Xshareclasses:name=zeam01,destroy
JVMSHRC010I Shared cache "zeam01" is destroyed
□ 15. You have completed the Java Shared Cache lab.
z/OS Java Exploiters and Java Batch
Lab 5: Java Shared Class Cache
Last Updated: 2012-04-19
Page 8 of 8
©2012 IBM Corporation
IBM Wildfire Series
z/OS Java Exploiters and Java Batch
Unit 6: Introduction to Rational Application Developer for z/Series
WSC Wildfire Class
November 28, 2012
© 2012 IBM Corporation
IBM Wildfire Series
Rational Application Developer for z/Series
http://www-01.ibm.com/software/rational/products/developer/systemz/devsysz/
“Provides an interactive,
workstation-based environment
where you can connect to a mainframe
and develop mainframe-based applications in COBOL,
PL/I, Assembler, C/C++, and Java,
as well as workstation-based applications in COBOL,
PL/I, and Java.”
2
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
z/OS Java Exploiters and Java Batch
Unit 7: Java Support in CICS Transaction Server
WSC Wildfire Class
November 29, 2012
© 2012 IBM Corporation
IBM Wildfire Series
CICS Java-Related Capabilities (CICS V4R2)
• Java CICS applications - ordinary CICS transactions that are written in Java
• CICS Transaction Gateway (CTG)
• CICS Web Support – enables CICS to be an HTTP Server
Deprecated: Avoid using the following technologies in new CICS
applications
•
Stateless CORBA objects and IIOP – Java server applications that use
the IIOP protocol
•
Enterprise Java Beans (EJBs) – EJB Version 1.1 - Session beans only
No Servlet support in CICS
public class HelloWorld extends HttpServlet -> Not available
Publications:
Java Applications in CICS V4R2, SC34-7174-00
Redbook: JCICS and the JVM server - Developing and Deploying Java applications, SG24-8038
2
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Java requirements in CICS TS
 CICS TS 4.2
– Requires Java V6.0.1, 64 bit version.
– Requires z/OS V1R11 or higher
– Became available June 24, 2011
 CICS TS V4.1
– Requires Java V6.0, 31 bit only. Can also use Java
V6.0.1, 31 bit only.
 CICS TS V3.2
– Requires Java V1.4.2 or Java V5 (preferred), 31 bit
only.
3
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Java implementation in CICS V4.1 and earlier
Pooled JVMs
 Each Java program uses its own JVM, although JVMs are reused after a
transaction program ends.
 CICS starts a pool of JVMs. Each JVM runs on an MVS Task Control Block
(TCB), so multiple tasks can be handled concurrently.
– Key point: Multiple TCBs are used. If the application running on an open TCB invokes a non-CICS
service which blocks the TCB, the TCB blocking does not affect other CICS tasks.
 The number of JVMs in the pool is managed by CICS, limited by SIT parm
MAXJVMTCBS (default 5).
– CEMT INQUIRE JVMPOOL - tells how many JVMs are currently running
– JVMs stay around for 30 minutes by default after last use. The time can be set
in the JVM profile using the IDLE_TIMEOUT parameter.
 Pooled JVM support will be removed in a future release of CICS.
 For compatibility with pre-CICS V4.2 programs, Pooled JVMs are supported in
CICS V4.2.
4
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Pooled JVMs – Conceptual view
• Each program runs in a separate JVM. The shared class cache
can be used to reduce storage requirements.
5
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Java implementation in CICS V4.2 and later
JVM Server runtime environment
 JVM Server is the strategic runtime environment for Java applications in
CICS
 A JVM Server can handle multiple concurrent requests from different
Java applications in a single JVM
 Java applications must be threadsafe and comply with the OSGi
specification
– Simple definition of threadsafe: An application that uses appropriate
serialization techniques when accessing shared resources
– See Redbook Threadsafe Considerations for CICS, SG24-6351-03
 Development must be performed using the CICS Explorer SDK
– CICS Explorer SDK is a free plug-in for Eclipse
6
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
JVM Server – Conceptual view
• Multiple Java programs run in a single 64 bit JVM.
7
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
What is OSGi?
OSGi: Open Systems Gateway Initiative Framework
Courtesy of the OSGi Alliance, www.osgi.org
8
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Enabling JVMServer Java Support in CICS V4R2
 Setup is generally similar in earlier releases of CICS
 Ensure that CICS Java libraries are installed and have appropriate RACF
security control and permissions and other authorizations
– /usr/lpp/cicsts/cicsts42  CICS library that contains Java packages
– hlq.CICS.SDFJAUTH  must be APF authorized)
 Specify the JVMPROFILEDIR in the SIT
JVMPROFILEDIR=/u/zeam01/cicslab/JVMProfiles
 Specify the USSHOME in the SIT
USSHOME=/usr/lpp/cicsts/cicsts42
 Specify EDSALIM value in the SIT as 200 MB or greater (Extended
Dynamic Storage Area)
 CICS region size should be 400 MB or greater
Note that all of the above is done only by z/OS system programmers
and CICS administrators.
CICS programmers do not normally deal with configuring the above
values.
9
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
CICS Definitions when using JVMServer
 Program Resource Definition
– JVM = Yes
– JVMClass=name.of.mainClasstoRun
– JVMServer=name of JVMServer resource definition
 JVMServer Resource Definition
– Contains name of JVMProfile to use
 JVMProfile (HFS file)
– An HFS file located in directory specified by JVMPROFILEDIR
in SIT
– Specifies JVM path and, optionally, many parameters
– Also specifies JVM options (e.g. Xmx=256M)
10
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
CICS Java Program Resource Definition (Screen 1 of 2)
11
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
CICS Java Program Resource Definition (Screen 2 of 2)
12
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
CICS JVMServer Resource Definition
13
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
JVM Profile for a JVMServer (DDWOSGI HFS file)
JAVA_HOME=/usr/lpp/java/J6.0.1_64
# ********* JVM options **********
-Xms64M
-Xmx512M
 The JVMPROFILEDIR parameter in the SIT specifies the
name of the directory that contains the JVM Profiles.
 The only entry that is required is JAVA_HOME.
 In the lab, you will see a real JVM Profile with many entries.
14
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
JCICS Classes are provided to access most CICS services


















15
ABEND initiation and handling
APPC mapped conversations (but not unmapped)
Basic Mapping Support (BMS) (except for SEND MAP or RECEIVE MAP)
Channels and Containers
Diagnostics Services (ENTER, TRACE) (except for DUMP)
Document Services
Environment Services
File Services – KSDS, ESDS, RRDS
HTTP and TCP/IP Services
Program Services (LINK, RETURN, XCTL) (except for SUSPEND)
Scheduling Services (CANCEL, RETRIEVE, START)
Serialization Services (DEQ, ENQ)
Storage Services – No, we don’t support GETMAIN explicitly. Java manages storage on its own.
Temporary Storage Queue Services
Terminal Services (except for HANDLE AID and WAIT TERMINAL)
Transient Data Queue Services
Unit of Work Services
Web Services
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
JBMS – Java Basic Mapping Support
 Provides an interface to the 3270 terminal, which is much like the
corresponding BMS service in traditional CICS programming
 Unsupported and experimental – Created by Redbook team
 See section 6.13 of Java Application Development for CICS,
SG24-5275-03
 Package is:
com.ibm.itso.sg245275
16
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Simple CICS Program
import com.ibm.cics.server.*;
public class DoIt {
public static void main (CommAreaHolder CAH) {
byte MyCommArea[] = CAH.value();
.
.
 Import statement indicates package containing JCICS classes
 The class only needs to contain one method
 Execution begins at the 'public static void main(CommAreaHolder CAH)' method
 A static method always exists
17
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Region and Task Objects
import com.ibm.cics.server.*;
public HelloWorld class {
public static void main(CommAreaHolder ca) {
Task myTask = Task.getTask();
myTask.out.println("I am running in "+
Region.getAPPLID()+".");
myTask.out.println("I am going to abend");
myTask.abend("ERR3");
}
}
 A printwriter named out (and err) is available to the Task. It writes to a terminal, or to the
CESO/CESE destination if not associated with a terminal
 Region.getAPPLID() is like
EXEC CICS ASSIGN APPLID(location) END-EXEC.
 The last line of code is equivalent to
EXEC CICS ABEND ABCODE(“ERR3") END-EXEC.
18
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
CICS TSQ (Temporary Storage Queue) Write: COBOL
*
*
*
19
EXEC CICS WRITEQ TS QUEUE("DENNIS")
MAIN
FROM(TSQ-MSG)
LENGTH(LENGTH OF TSQ-MSG)
RESP(RESP-FLD)
END-EXEC.
EVALUATE RESP-FLD
WHEN DFHRESP(LENGERR)
---> code for length error here
WHEN DFHRESP(NOSPACE)
---> code for out of space condition
WHEN DFHRESP(ITEMERROR)
---> code for item error here
END-EVALUATE.
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
CICS TSQ (Temporary Storage Queue) Write: Java
TSQ myTSQ = new TSQ();
myTSQ.setName("DENNIS");
myTSQ.setType(TSQType.MAIN);
String myMsg = "Message to be written to my TSQ");
try {
int numItems =
myTSQ.writeItem(myMsg.getBytes());
System.out.println("Just wrote item "+numItems);
} catch (LengthErrorException a) {
System.out.println("Length error writing item");
} catch (NoSpaceException b) {
System.out.println("No space to write item");
} catch (ItemErrorException c) {
System.out.println("There was an item error");
} catch (Throwable t) {
System.out.println("Unexpected Throwable:"+t);
}
20
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
z/OS Java Exploiters and Java Batch
Labs 7a and 7b: Java and CICS
WSC Wildfire Class
© 2012 IBM Corporation
IBM Wildfire Series
CICS Lab Exercises
Inbound Web Support:
Web
Browser
CICS TS
Business Function with Browser Interface
CICS
HTTP
Listener
support
Interface
logic
Data
access
I
D
•
Interface Logic Program and Data access program written in Java
•
Interface Logic
•
HTTPRequest object to get input from HTML form
– Calls Data Access Program
– Uses Document API and HTTPResponse object to return data
 Data Access
– Uses JCICS classes to do Create/Read/Update/Delete on VSAM file
22
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Lab 7a: CICS TS V4R2 with CWS and Java
 A “review and examine” exercise
 Uses pooled JVMs – like in CICS V4R1 and earlier
 Logon to TSO
– View CICS Java programs and configuration files in HFS
 Start your CICS region
 Connect (Logon) to CICS via 3270 interface
– Issue various CICS commands to view resources
 Invoke CICS Java program from a browser
23
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Lab 7b: CICS TS V4R2 OSGi REST application
development
 You will use RDz to build and install an OSGi-compliant
application.
 The Java programs are already written.
 This lab uses the new JVMServer support.
 This is an advanced lab that should be performed in teams
of two people. Preferably, at least one of the team
members should have some Eclipse or RAD experience
and one of the team members should have some CICS
experience.
 Most – but not all – of the CICS definitions have already
been created. You are urged to review the definitions to
enhance your knowledge of the CICS JVMServer
implementation.
24
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM – Java – zSeries Seminars
Lab 7a: CICS TS V4.2 – A simple Java application using pooled
JVMs and a CICS Web Server for browser presentation
Lab Version V1.19
November 29, 2012
This lab is based on materials created by
Dennis Weiand and Leigh Compton of the
CICS, Web & Java North America ATS Team
© Copyright IBM Corporation 2011 All rights reserved.
Overview
The purpose of this exercise is to illustrate the use of Java as a language for writing CICS programs.
Additionally, this lab exercise will provide an introduction to CWS (CICS Web Support) as a way to
provide browser access to CICS programs.
Scenario
In our scenario, you work for a mutual fund company and will implement a simple application that can
create, read, update, and delete fund information. Currently, the program to access fund information is
written in COBOL, but someone in your programming department has recently rewritten the program in
Java as a Proof-of-Concept (PoC). It is likely that if the PoC succeeds, your company will be using Java
as a CICS programming language where it can gain a business advantage for your company.
The old application used a 3270 interface to the COBOL program, but the new Java version needs to be
accessed by a browser. The application is internal to your company, but direct, external customer
access, will be considered in the future.
For simplicity, our implementation of the application only stores a fund id, the fund name, a fund rating,
and a fund price.
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 2 of 20
© Copyright IBM Corporation 2011 All rights reserved.
Note: The directions in this exercise rely on certain datasets, programs, and userids to be available
in a zOS environment. For this lab exercise, you will use a TSO userid of ZEAM01. We have
supplied some JCL for you in a data named ZEAM01.JCL.CNTL.
Lab Requirements
Please note that there are often several ways to perform functions in and for CICS. This lab exercise
will present one of the ways. If you are familiar with CICS, you will notice that some of the statements
are general, and not necessarily true for every situation.
This lab exercise assumes some knowledge of ISPF and editing files on zOS, but does not assume much
knowledge of CICS, CICS facilities, and CICS resource definition. If you are not familiar with ISPF,
editing files, and submitting jobs, please contact one of the lab instructors.
The following are other assumptions made in this lab exercise.
 CICS TS V 3.1, V3.2, V4.1, V4.2: This lab exercise uses facilities and naming conventions that
were introduced in CICS TS V3.1. CICS Java support must be in place. The CSD has some
resources already defined.
 Login: TSO userids are available with the names ZEAM01.
 Data files: Datasets named ZEAM01.CICSLAB.CNTL contain JCL to start CICS, define a VSAM
file, and also contain a copy of the original COBOL application program. Home directories
(/u/zeam01/cicslab) are also defined and contain HTML, JavaScript, Cascading Style Sheets, and
CICS Java programs with associated support classes.
Lab Steps
Part 1: Configure CICS to Listen for Browser requests
In this part of the lab, you will tell CICS to listen for HTTP request on a specific port. To do
this, some initialization parameters must be set, and a CICS resource definition must be made to
indicate the port number to listen on, and the protocol (HTTP) to be expected.
Part 2: Tell CICS what to do with incoming HTTP requests
This part of the lab exercise has you map incoming HTTP request from browser to files and
programs in CICS. For some browser request, CICS just needs to return an HTML file, a
graphic, or a similar file, but for browser requests that create, read, update, or delete application
data, CICS will need to invoke a program.
Part 3: Define Java programs to CICS
This is where you will define your Java programs to CICS. We will also discuss how we tell
CICS how to run your program and where to find it.
Part 4: Prepare the Java programs for use by CICS
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 3 of 20
© Copyright IBM Corporation 2011 All rights reserved.
As with any CICS program, you need to compile your program and make sure it is in the right
place.
Part 5: Understand the Java program
In this part of the lab exercise, we will discuss the various parts of the Java program that perform
the business logic. We will compare this to the original business logic which was written in
COBOL.
Part 6: Sending Output from the Java program to the Browser
This part covers the Java program that accepts browser requests, formats a COMMAREA to pass
the data request to the Java program that performs the business logic.
Part 7: Definition of the VSAM file for application Data
This part talks about where the application stores its data.
Part 8: Testing the Application
Ok, now we will watch the application work.
Part 9: Summary
This is a recap of the steps performed in this lab exercise.
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 4 of 20
© Copyright IBM Corporation 2011 All rights reserved.
Part 1: Configure CICS to Listen for Browser Requests
To tell CICS to listen for browser requests, we need to add TCPIP=YES to the SIT (System
Initialization Table) to tell the CICS startup to include TCPIP support. We will need to make a
TCPIPService definition to tell CICS what port to listen on. We will also look at the CICS SIT options
which are contained in a PDS member.
Tip: The CICS SIT (System Initialization Table) contains indicators as to what support CICS
should contain when it initializes. The type of information in the SIT includes information like the
type of resources CICS should initially make available, security information, and whether TCPIP
support should be included. There are many CICS initialization options, so these are only a few.
The TCPIPService definition that tells CICS which TCPIP port to listed on is created via RDO
(Resource Definition Online). CICS resource definitions are held in a VSAM file called the CSD (CICS
System Definition), so when adding the TCPIPService definition we will start CICS and use a supplied
transaction called CEDA to define or view CICS resources.
___1. Logon to TSO using your zeam name (ZEAM01) and your zeam password
Note: We are using PCOMM for 3270 emulation. On your desktop, you will find icons for
connecting to TSO and to CICS. Double-click one of these icons to start a 3270 session.
___2. Use ISPF and look at ‘ZEAM01.CICS.SYSIN(SIPZM01)’. Ensure that TCPIP=YES is
specified. This dataset member is pointed to by the JCL that starts our CICS region.
Note: Contact one of the lab assistants if you are not familiar with ISPF, editing files on zOS,
or submitting jobs.
___3. Start the CICS region by issuing /S CICSZJAV from SDSF (option D from ISPF) .
___4. After your CICS region has started, connect to the CICS by entering ‘CICS’ from a 3270
emulation session.
___5. Clear the screen (by pressing the Pause key) and enter ‘ceda expand group(labgrp)’. The
CEDA transaction will expand (list) all of the resources grouped together in a group called
‘labgrp’. We have already defined some of the CICS resources needed for this lab exercise, but
you will need to verify that they are correct, and you will need to get information from these
resource definitions.
___6. On the screen showing the CICS resources in the group ‘labgrp’, type ‘view’ by the
TCPIPService that is named ‘DDWTC1’ and press the enter key. This will allow you to view
the contents of the DDWTC1 TCPIPService resource definition.
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 5 of 20
© Copyright IBM Corporation 2011 All rights reserved.
Tip: Use PF7 and PF8 to scroll back and forth in the resource definition. If you press the enter key,
you will return to the resource listing. If you accidentally pressed the enter key before you were done
viewing the resource, but type the word ‘view’ by the resource and press the enter key.
___7. Verify that the Portnumber is 23401. You will be using this port number when you solicit
information from your browser.
___8. Note that the Protocol is Http. This means that CICS should expect to receive HTTP over this
TCP/IP connection.
Tip: CICS is very flexible to accommodate your various needs. A few other items that you might
want to notice in the TCPIPService definition are a section on security, a section on DNS
connection balancing for availability, a URM (user replaceable module) to alter some of the
default CICS behavior, and the ability to assign a specific transaction id for security or to more
easily track the performance of this resource.
___9. The CICS resources were automatically installed when CICS started. If they were not
configured to automatically install at CICS startup, you could have installed the resources by
entering ‘install group(labgrp)‘ at the top of the screen.
___10. Exit the CEDA transaction by pressing PF3 and clearing the screen.
___11. From a clear screen, enter ‘cemt inquire tcpipservice’ and verify that the status of the
DDWTC1 TCPIPService is ‘Ope’ (open).
Tip: CEMT is the name the CICS supplied master terminal command. This transaction is used to
display status, alter, and remove resources in an actively running CICS region.
___12. Exit the CEMT master terminal transaction by pressing PF3 and clearing the screen.
Part 2: Tell CICS What To Do With Incoming HTTP Requests
You have told CICS to accept HTTP over TCP/IP requests on a specific port. In this part of the lab
exercise, you will tell CICS what to do when it receives an HTTP request.
When we think of using a browser to access a system, we normally think of the initial text and
information that is sent to the browser. This initial text almost always points to additional files that must
be sent to the browser to construct the page. These files may include graphics, Cascading Style Sheets,
JavaScript, and even sound files.
When you request a page from a browser, you type in a specific type of URI (Universal Resource
Identifier) called a URL (Uniform Resource Locator). A URL normally locates an existing resource on
the Internet. A URL is made up of 3 or 4 components. The first is called a scheme which specifies the
protocol to be used. Next is the host which usually specifies a DNS or TCP/IP address. After the host
is an optional port. The port defaults to a ‘well-know’ port number depending on the scheme. For
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 6 of 20
© Copyright IBM Corporation 2011 All rights reserved.
example, if you specify a scheme of http and no port, the port will default to 80. Next is the path which
indicates the resource to be accessed. The last part is optional and is called the query string which is
information to be passed to the resource specified in the path.
scheme://host:port/path?query
This section looks at the resource definitions that tell CICS what to do when it receives a URL as
discussed above. These definitions are new to CICS TS V3.1 and are called URIMAPs.
___1. From a clear screen connected to CICS, enter ‘ceda expand group(labgrp)’ to list the resources
that reside in the ‘labgrp’ group.
___2. Type ‘view’ by ‘DDWURI1’ to view the first URI. Under Path, you see ‘fund/*’. Page forward
a few pages and you will see an HFS file of ‘/u/zeam01/cicslab/html/*’. This tells CICS, for
example, when it receives a request like http://your.company.com/fund/index.html, that it should
send back the file found in /u/zeam01/cicslab/html/index.html. Additionally, the definition is
telling CICS to inform the browser that the information is ‘text/html’, that the file is currently in
codepage 037 (North American EBCDIC) and that the page should be sent to the browser in the
ISO 8859-1 codepage.
The ‘text/html’ is called a Mime type. These mime types tell the browser how to interpret the
file. For example, you would want to indicate to the browser that a cascading style sheet is
‘text/css’ and not ‘text/html’. Some browsers guess how you intended the file to be used
(Microsoft Internet Explorer), but Mozilla based browsers obey the specified mime type. Being
accurate on the appropriate mime type will help avoid the type of error where some pages may
appear to display properly on some browers but not on others.
Tip: We have constructed some web pages for you. These are ‘normal’ web pages with references
to javaScript, graphics, and Cascading Style Sheets that the browser then downloads and merges
with the HTML page. We will serve all these elements from CICS, so in addition to html, we will
need to tell CICS what to do with these other file requests also. When serving multiple types of
files, you normally organize the files into different directories based on their mime type.
Note: All pages would not have to be served by CICS. In most situations you would probably find
the HTML, and associated files served by a Web Server. This exercise illustrates that CICS is
capable of serving files and that you have the flexibility to serve the appropriate files from the
appropriate location for your application (which may be CICS in some situations or a web server
in other situations).
The definitions that are required to be in CICS, are those that tell CICS what to do when we
request a program invocation, and ‘templates’ that CICS can use to help formulate a response from
a program invocation.
___3. View the DDWURI2 resource definition to see what CICS should do when the path information
requests a resource from fund/scripts/* (the HTML pages we supply specify this path for
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 7 of 20
© Copyright IBM Corporation 2011 All rights reserved.
JavaScript files).
___4. View the DDWURI3 resource definition to see what CICS should do when the path information
requests a resource from fund/css/* (the HTML pages we supply specify this path for Cascading
Style Sheet files).
___5. View the DDWURI4 resource definition to see what CICS should do when the path information
requests a resource from fund/graphics/* (the HTML pages we supply specify this path for
graphics).
___6. The DDWURI5 resource definition indicates what should be done if CICS requests a path of
‘fund’. In most Web Servers, when a directory name is provided with no specific resource or
file name provided, the Web Server will look for a standard set of file names like index.html,
welcome.html, etc. CICS does not have a default like this, so if we want CICS to send the
fund/index.html page when it sees ‘fund’, we need to tell CICS. DDWURI5 allows for this
situation.
___7. For a path that invokes a program in CICS, view the DDWURI6 definition. The DDWURI6
definition associates a path of fund/prog/HttpReq1 with a program defined to CICS as
HTTPREQ1. The HTTPREQ1 program definition in CICS points at a Java program which we
will talk about in the next section.
___8. If you would like to view the HTML pages, go to /u/zeam01/cicslab/html and browse the files.
See the Cascading Style Sheet files in /u/zeam01/cicslab/css, and see the javaScript files in
/u/zeam01/cicslab/scripts.
Although we don’t have a utility for you to view them, the graphics files are in
/u/zeam01/cicslab/graphics.
Note: When preparing the HTML and associated files, we used various resource editors in
Rational Application Developer (RAD). The tools provided with RAD make Web Development
tasks very easy.
___9. You are ready to test the initial HTML page because the CICS definitions are in place, and we
have supplied some HTML and associated files.
___10. Start a browser, and enter http://wg31.washington.ibm.com:23401/fund as the URL. You
should see the following screen displayed. Do not go past the initial page since we are not ready
to test that yet.
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 8 of 20
© Copyright IBM Corporation 2011 All rights reserved.
Part 3: Define Java Programs to CICS
In a 3270 based CICS application, you would invoke a program from a 3270 device with a 1 to 4
character transaction identifier. The invoked program could return a BMS (CICS’s Basic Mapping
Support) map (a ‘form’ in browser terminology) to solicit information from the user, or the program
could take the data sent in from the 3270 device and prepare a COMMAREA (Communications Area) to
be passed to program that contains the business logic.
In this application, we will use the same approach. We have a backend program previously written in
COBOL but now written in Java, and also a program that understands the format of the data from the
input device (a browser in this situation), and knows how to format the data for the backend business
logic program.
When using a 3270 approach, a CICS program gets information from the backend program containing
the business logic and then merges the information with 3270 screen layout defined in a ‘MAP’. Again,
we are using the same approach when using a browser. Instead of CICS BMS (Basic Mapping Support)
commands in our application program, we are using the “Document API” supplied by CICS. We will
use this approach to merge information solicited from the backend program with an HTML page to be
sent back to the browser.
In this part of the exercise we are going to look at the definition for the Java program that will supply the
business logic (FUNDREQ1), and the Java program that sends and receives information to/from the
browser.
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 9 of 20
© Copyright IBM Corporation 2011 All rights reserved.
___1. From your 3270 session connected to CICS, from a clear screen, type ‘ceda expand
group(labgrp)’.
___2. Type view next to HTTPREQ1 and press the enter key to view the HTTPREQ1 program
definition. There are a lot of options here, but the important options for a Java program are
JVM=Yes, the name of the class to be invoked, and the JVMProfile. The JVMProfile points to a
file in /u/zeam01/cicslab//JVMProfiles (which is the directory specified by JVMPROFILEDIR
in the SIT). This profile contains information such as the type of JVM to run (continuous) and
the CLASSPATH where the class specified in the JVMClass attribute is located.
___3. Use your OMVS session and look at /u/zeam01/cicslab/JVMProfiles/DFHJVMPR. Look for
CLASSPATH_SUFFIX=. This should be set to point to /u/zeam01/cicslab/classes. This is the
directory where we have put the ibm.ddw.HttpReq1 class specified in the HTTPREQ1 program
definition. If the CLASSPATH_SUFFIX is missing or commented out, add it to the
DFHJVMPR file, then stop and restart CICS. (To stop CICS, issue CEMT PER SHUT from
your CICS session screen. To restart CICS, issue /S CICSZJAV from =D.LOG under ISPF in
your TSO session.)
___4. Back in the 3270 terminal connected to CICS, view the resource definition for the FUNDREQ1
program. This definition also uses the DFHJVMPR profile, with the initial class being invoke as
ibm.ddw.FundProg.
___5. View the DDWDOC1 TEMPLATE resource definition in CICS. As indicated before, our
application uses the CICS WEB API to merge the results from our backend program with HTML
that is sent back to the browser. The HTML to be merged with the data returned from our
business logic is called a TEMPLATE. Template information can be stored in HFS, DB2,
VSAM, a PDS, queue, or returned from a program. In our case we stored the HTML template in
an HFS file. When a CICS application program references the templatename
(FundHtmlOut.html), CICS will access the data in
/u/zeam01/cicslab/templates/FundHtmlOut.html.
Part 4: Prepare the Java Programs For Use With CICS
When compiling Java programs that run under CICS, you can take two different approaches. You can
compile them on zOS using the ‘javac’ program, or since Java is write-once-run-everywhere, you could
compile the program on a workstation.
When developing the FundProg and HttpReq1 Java programs, we used Rational Application Developer
(RAD). We downloaded the dfjcics.jar Jar file that contains the CICS classes that allow you to access
CICS resources to RAD. This Jar file is in /usr/lpp/cicsts/cicsts41/lib/dfjcics.jar. Downloading this file
allowed us to take advantage of the code assist, syntax checking, compilation, and other productivity
features available in RAD. After developing the code and saving it (which automatically compiled the
code), we only had to transfer the Java byte-code to our zOS HFS directory.
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 10 of 20
© Copyright IBM Corporation 2011 All rights reserved.
In some production scenarios, you may not want application programmers to transfer the bytecode they
compiled on their workstation directly to production libraries. You may wish to take the Java source
code from your SCM (Source Code Maintenance) system and compile it. This is probably similar to
what you are currently doing during your production turnover. This may be as simple as typing in a
command line, or may include the use of a make file or an Ant script.
___1. In this step, you will verify that the classes for the FundProg and HttpReq1 Java programs are
available. Note that we specified the class for the FUNDREQ1 program as ibm.ddw.FundProg.
We could have placed the Java application class files in a Jar file, but for this simple exercise, we
left them in a directory structure.
Change your current directory to /u/zeam01/cicslab/classes. You will see a subdirectory called
ibm. Change your current directory to the ibm subdirectory. You should see a subdirectory
called ddw. Inside /u/zeam01/cicslab/classes/ibm/ddw you will see the FundProg.class and
HttpReq1.class files. You will also see a directory called bytearea. This directory contains some
utility classes we used for conversion between the COMMAREA and the object oriented world
of Java.
Note: If we had placed the classes in a Jar file, we would have needed to specify the name of the
Jar file in the CLASSPATH_SUFFIX in the JVMProfile. Additionally, you would have seen the
Jar file in the /u/zeam01/cicslab/classes directory.
Part 5: Understanding the Java Program
You can use Java in several places in CICS. You can use Java programs as
 Regular CICS programs
 Initial program of a transaction

Started by a user of an EXEC CICS START
 Target of an EXEC CICS LINK

Target of an EXCI call of DPL including ECI
 Target of a Web Service call
 Target of EXEC CICS XCTL
 Program named in EXEC CICS HANDLE ABEND command
 Initialization program or shutdown program
 Some User Replaceable Module (URM)
 Inbound IIOP object implementation
 Enterprise JavaBeans
The major areas you will need to address when migrating applications to Java, or writing new
applications in Java are:

Data Areas

Accessing environment information

Accessing CICS Resources
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 11 of 20
© Copyright IBM Corporation 2011 All rights reserved.
Data Areas
CICS supports many different languages, so when passing data between programs, the data is in a ‘flat’
structure instead of objects. The most notable exception to this is that when using Enterprise JavaBeans
(EJBs) in CICS, you can pass data by specifying arguments on method calls as you would between EJBs
running on any platform.
When accessing CICS resources and passing data to or receiving data from these resources, the data is
also passed in a ‘flat’ manner. When we refer to ‘flat’ data, we mean that the data is stored very
similarly to a byte array in Java.
To accommodate the byte array to Java object conversion, you can use various techniques such as
concatenation, substring, indexing, or bytestreams. This approach may be a bit time consuming if you
write code to apply this to each data layout you wish to pass to and from a CICS resource or program.
Although this may perform better in some individual cases, a better technique is to write generic classes
or to use the support for generating conversion classes in RAD (Rational Application Developer)
Version 6.0.1 or higher. RAD can take a COBOL, PL/I, or C data layout and generate an object that
will convert between the COBOL, PL/I, and C data structures and Java data formats.
The Java program we supplied currently uses generic classes we wrote to do this conversion, although
we intend to change the program to use objects generated by RAD.
___1. Change directory to /u/zeam01/cicslab/source/ibm/ddw and browse the FundProg.java file
containing the Java program.
___2. Towards the top of the file, you will see a section that looks like the following:
ByteAreaLayout commArea = null;
String[] fundCommAreaRecordDescription = {
/*
LINKAGE SECTION.
01 DFHCOMMAREA.
03 REQUEST-TYPE
PIC X.
03 RET-CODE
PIC XX.
03 FUND-ID
PIC X(8).
03 FUND-NAME
PIC X(50).
03 FUND-RATING
PIC X.
03 FUND-PRICE
PIC X(15).
03 RETURN-COMMENT
PIC X(50). */
//---> type C=Character, N=display number, B=two byte signed binary
//--->
fld Name
type len initial value
//---> --------------- --- ----------------"REQUEST-TYPE",
"C", "1", "",
"RET-CODE",
"C", "2", "",
"FUND-ID",
"C", "8", "",
"FUND-NAME",
"C", "50", "",
"FUND-RATING",
"C", "1", "",
"FUND-PRICE",
"C", "15", "",
"RETURN-COMMENT",
"C", "50", "",
"END-OF-ITEMS" };
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 12 of 20
© Copyright IBM Corporation 2011 All rights reserved.
___3. These are generic classes that allow us access information in the COMMAREA with statements
like “commArea.getValue("FUND-ID")” or “commArea.setValue("FUND-ID", "00000001")”
later in the program. As indicated above, using an IDE like RAD to generate classes to perform
this function for you is preferable to writing and maintaining your own code.
___4. If you didn’t use your own generic classes or classes generated by an IDE like RAD, you could
use something similar to the following Java statement.
String fundId = new String(commArea.getBytes(), 3, 11);
Accessing CICS Resources
In most of these types of Java programs you will want to access CICS resources such as TD Queues and
VSAM files. CICS provides the JCICS class library to allow your Java programs to perform most
functions available in the EXEC CICS API.
___2. In the FundProg.java file, search for KSDS. The first occurrence is an import statement, so go to
the second occurrence. You will find the code looks as follows:
try {
KSDS fundFile = new KSDS();
fundFile.setName("FUNDFILE");
writeToCsmtQueue(commArea.toString());
fundFile.write(fundFileLayout.getValue("FUND-FILE-ID").getBytes(),
fundFileLayout.getBytes());
setGoodReturnCodeInCommArea("Fund added");
} catch (DuplicateRecordException dre) {
addErrorInfoToCommArea("04", "Fund alread exists");
} catch (Throwable t) {
addErrorInfoToCommArea("04", "Problem adding fund, see CICS "+
"message log");
}
___3. When accessing CICS resources (and most all of them are accessed the same way), you
instantiate an object that is the type of resource that you want to access. In this case we are
working with a KSDS file, so we instantiate a KSDS object.
___4. You then set the name of the resource. This is the name by which CICS knows the resource. In
a later step we will define a FILE resource to CICS and we will tell CICS the name of the file
resource is FUNDFILE.
___5. Then, you use a method on the object that corresponds to the action you want to take. In the
code above, we are requesting a ‘write’ on the fundFile (KSDS) object. The arguments vary
depending on the method, but in this case, the write method takes two arguments, both of which
are byte arrays. The first argument is the file key, and the second argument is the record data.
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 13 of 20
© Copyright IBM Corporation 2011 All rights reserved.
This may seem complex at first, but is identical in concept to the EXEC CICS commands.
Additionally, if you are using an IDE like RAD, the IDE will help with code assist, method
completion, knowing what methods are available, syntax, etc.
You will note that the resource access is in a try-catch block because it can throw exceptions.
The exceptions correspond to the exceptions that the equivalent EXEC CICS command can have.
In the code above, we are specifically checking for a duplicate record exception. All other
exceptions like not authorized, IO error, etc are being caught with the catch for Throwable.
___6. The COBOL code from the original program that corresponds to the above section of code is
shown below. It is very easy to see the similarities.
EXEC CICS WRITE FILE('FUNDFILE') RIDFLD(FUND-FILE-ID)
FROM(FUND-FILE-LAYOUT) RESP(RESP-FLD) END-EXEC.
EVALUATE RESP-FLD
WHEN DFHRESP(NORMAL)
MOVE '00' TO RET-CODE
MOVE 'Fund added' TO RETURN-COMMENT
PERFORM 7100-RETURN-ERROR-MESSAGE
WHEN DFHRESP(DUPREC)
MOVE '04' TO RET-CODE
MOVE 'Fund already exists' TO RETURN-COMMENT
PERFORM 7100-RETURN-ERROR-MESSAGE
WHEN OTHER
MOVE '04' TO RET-CODE
MOVE 'Problem adding fund, see CICS message log'
TO RETURN-COMMENT
PERFORM 7100-RETURN-ERROR-MESSAGE
END-EVALUATE.
Accessing Environment Information
In typical CICS programs you access information about the CICS environment. For example this might
be the name of the CICS VTAM applid ( with an EXEC CICS ASSIGN ). With Java in CICS, there are
some static objects (for example the Region object), where you can get this information (for example
Region.getApplid() ).
For items like the COMMAREA length, CICS supplies a bock of information to procedural languages
called the EIB (Execute Interface Block). For the COMMAREA length, the EIB has a field in it called
EIBCALEN (for EIB CommArea Length). In a Java program, you can test the length of the passed area.
___7. In the Java code below, the COMMAREA (information passed to this program) arrives in the
variable called ‘ca’. The length of the COMMAREA is ca.value.length. You will also note that
an object that represents this task (called myTask) is obtained from the global static Task object.
This representation of the current task is needed for actions like requesting an ABEND, taking a
SYNCPOINT, or requesting a ROLLBACK for the transaction.
public FundProg(CommAreaHolder ca) {
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 14 of 20
© Copyright IBM Corporation 2011 All rights reserved.
myTask = Task.getTask();
// get this task’s task object
if (ca.value.length != 127) { // if the commarea is not the right size
myTask.abend("FUN1");
// abend with an abcode of FUN1
}
Part 6: Sending Output from the Java Programs to the Browser
As indicated above, you would normally have a CICS program receive information from a device or
client, and format the data for use by a CICS program containing your business logic. After the
invocation of the business logic, the result are formatted as appropriate and sent back to the browser.
The following steps illustrate the code to perform functions.
___1. Open the HttpReq1.java code in /u/zeam01/cicslab/source/ibm/ddw and follow along with the
steps below.
___2. When an HTTP request is received from the browser for the HTTPREQ1 program (discussed
above), the HTTPREQ1 CICS program can access the query string on the request via an
HttpRequest object and associated getFormField() methods.
public HttpReq1(CommAreaHolder ca) {
myTask = Task.getTask();
// get task object for this transaction
HttpRequest hr = HttpRequest.getHttpRequestInstance();
___3. The HTTPREQ1 program takes this information obtained from the browser request and formats
it into a COMMAREA that it passes to the FUNDREQ1 program. The code below tests for a
request of “C” (for create) or “U” (for update) because these functions require additional fields.
A request for a read or delete only requires the FUND-ID to be present.
commArea = new ByteAreaLayout(fundCommAreaRecordDescription); //new COMMAREA
try {
commArea.setValue("REQUEST-TYPE", hr.getFormFieldData("requestType"));
String requestType = hr.getFormField("requestType");
commArea.setValue("FUND-ID", hr.getFormFieldData("fundId"));
if (requestType.equalsIgnoreCase("C") || requestType.equalsIgnoreCase("U")) {
commArea.setValue("FUND-NAME", hr.getFormFieldData("fundName"));
commArea.setValue("FUND-RATING", hr.getFormFieldData("fundRating"));
commArea.setValue("FUND-PRICE", hr.getFormFieldData("fundPrice"));
}
___4. The HTTPREQ1 program then invokes the FUNDREQ1 business logic program.
try {
Program pgm = new Program();
pgm.setName("FUNDREQ1");
pgm.link(commArea.getBytes());
___5. When the FUNDREQ1 business logic program returns the appropriate data, the HTTPREQ1
program takes the information from the returned COMMAREA, and merges it with a template.
Our template, in this case, is an HTML page containing symbols. CICS replaces the symbols in
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 15 of 20
© Copyright IBM Corporation 2011 All rights reserved.
the HTML page with the data associated with that symbol. For example, if we did an
addSymbol(“FUND-ID”, “00000001”) method, and the HTML document contained a “&FUNDID;”, the symbol (&FUND-ID;) would be replace with “00000001”.
An HttpResponse object is then used to send the merged data and HTML back to the requestor.
Document myDoc = new Document();
myDoc.addSymbol("FUND-ID", commArea.getValue("FUND-ID"));
myDoc.addSymbol("FUND-NAME", commArea.getValue("FUND-NAME"));
myDoc.addSymbol("FUND-RATING", commArea.getValue("FUND-RATING"));
myDoc.addSymbol("FUND-PRICE", commArea.getValue("FUND-PRICE"));
myDoc.addSymbol("RETURN-COMMENT", commArea.getValue("RETURN-COMMENT"));
myDoc.createTemplate("FundHtmlOut.html");
HttpResponse hResp = new HttpResponse();
hResp.sendDocument(myDoc,(short)0,"","8859-1");
(Optional) Part 7: Define the VSAM File for Application Data
This optional section discusses the application data for our Fund application. The COBOL version of
our Fund application accessed fund information from a VSAM file, so we left the information in VSAM.
When taking the time to migrate to Java, you may also want to take the time to reconsider your data
placement. If moving to a database will provide your application with a business advantage or allow
you to respond more quickly to user requests, this may be worth considering.
To use a VSAM file in CICS, you need to:

Define the VSAM file

Add a resource definition for the file to CICS

Use the JCICS classes to access the VSAM file from your Java program
___1. VSAM has been around for a long time so you are probably already familiar with defining
VSAM files. If you would like to view the definition of the VSAM file for this application, look
at ‘ZEAM01.CICSLAB.CNTL($0DEFtt)’ and search for ‘Create the fund file’.
___2. To view the CICS definition for FUNDFILE, from a 3270 terminal connected to CICS, clear the
screen and enter ‘ceda expand group(labgrp)’.
___3. Type ‘view’ next to the FUNDFILE FILE resource. Again, there are a lot of options when
working with any CICS resource, but some of the entries to be concerned with for our
application are the dataset name, and that you can add, browse, delete, read, and update the file.
___8. The JCICS classes to access the VSAM file were discussed above, but, in your Java code, you
would instantiate an object of the same type as the resource (a KSDS in this case), set a name on
the resource that corresponds to the name of the resource definition in CICS (FUNDFILE), and
then invoke the appropriate action to perform the action you desire. An example of writing a
record to a VSAM file is as follows:
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 16 of 20
© Copyright IBM Corporation 2011 All rights reserved.
try {
String recordDataString = “This is the record contents”;
Byte[] recordDataBytes = recordDataString.getBytes();
String recordKeyString = “00000001”;
Byte[] recordKeyBytes = recordKeyString.getBytes();
KSDS fundFile = new KSDS();
fundFile.setName(“FUNDFILE”);
fundFile.write(recordKeyBytes, recordDataBytes);
} catch (Throwable t) {
// check for errors here
}
Part 8: Testing the Application
In this lab exercise, we added a browser based interface to our application. A browser interface
could be added to any CICS program no matter what language it was written in. CICS has
several ways to access your back-end programs containing your business logic. These include
3270
WebSphere MQ
Web Services (from any client that can formulate a Web Service request)
CICS Transaction Gateway
Others
An advantage of writing your CICS programs in Java is that you can now use Java classes that
provide facilities that may not be available in other languages.
To test the application we will start a browser, enter a URL to access the Fund application, and
will exercises the various functions available on the application.
___1. Start a browser.
___9. Type in the URL ‘http://wg31.washington.ibm.com:23401/fund’. You should see the page
shown below.
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 17 of 20
© Copyright IBM Corporation 2011 All rights reserved.
___10. The Fund file currently contains no data, so select the Add Fund menu option on the left.
___11. Fill in some fund data and press the Add Fund button.
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 18 of 20
© Copyright IBM Corporation 2011 All rights reserved.
___12. Try all of the menu options and hyperlinks on the page to fully exercise the application.
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 19 of 20
© Copyright IBM Corporation 2011 All rights reserved.
Part 9: Summary
Congratulations, you have implemented and tested Java programs running under CICS. This Java
programs were accessed with a web browser.
In this lab you:

Configured CICS to Listen for Browser requests

Told CICS what to do with incoming HTTP requests

Defined Java programs to CICS

Prepared the Java programs for use by CICS

Looked a the logic in the Java programs

Sent the Output from the Java program to the Browser

Defined the VSAM file for application Data

Tested the Application
If you have any questions about anything you did in this lab exercise, please contact one of the lab
instructors.
11/29/2012
IBM – Java – zSeries Seminars
CICS TS V4.2 – CWS - JCICS
Page 20 of 20
IBM System z Wildfire Seminars – ZJAV1 – Java Exploiters
LAB 7B: PROVIDING A RESTFUL SERVICE IN CICS
Last updated: 2012-04-19
OVERVIEW
The purpose of this exercise is to create a RESTful service (as an OSGi bundle) that runs inside of CICS.
We will use RDz to create connections back to z/OS and CICS. Then we’ll build the services in RDz and
package them as OSGi bundles. Finally, we will deploy the bundle to CICS and test our application.
LAB REQUIREMENTS
 Java 6: This lab will also work with Java 5.
 UNIX® System Services: Please use your preferred method of accessing UNIX® System Services
(hereafter referred to as USS). You can go through OMVS (option 6 in TSO). Alternatively, you can
use a telnet client such as TeraTerm or Putty. Both utilities are provided on your workstation. Let
an instructor know if you need help.
 CICS: We are using CICS V4R2.
LAB STEPS
PART 1: STARTING CICS AND ESTABLISHING A CONNECTION FROM RDZ
You will start CICS on z/OS. You will create connections in RDz to the CICS Management
Interface, the CICS Resource Definition Server, and the z/OS Remote Systems Explorer daemon.
PART 2: JAVA DEVELOPMENT USING RDZ
Using pre-built source code, you will create several projects in RDz. You’ll create a OSGi bundle
to wrap these projects.
PART 3: DEPLOYING THE CICS BUNDLE TO Z/OS
You will deploy the OSGi bundle to CICS using the connections we created in part one.
PART 4: TESTING THE APPLICATION
You will use Firefox and the Poster plugin to test the application.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 2 of 52
©2012 IBM Corporation
PART 1: STARTING CICS AND ESTABLISHING A CONNECTION FROM RDZ
□ 01. Log on to TSO using ZEAM01.
Note:
You can use OMVS (option 6 in TSO) or a telnet client like TeraTerm or Putty. Both
TeraTerm and Putty have icons on the desktop.
Let an instructor know if you need help accessing USS.
□ 02. Start your CICS region.
In SDSF, issue the command: /s cicszjav
□ 03. On your desktop, double-click on the RDz icon.
□ 04. In the RDz menu bar, click on WindowPreferences.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 3 of 52
©2012 IBM Corporation
□ 05. In the Preferences window, click on CICS ExplorerCredentials.
□ 06. Click on New.
□ 07. Enter the following values and click Apply.
Field
Name
User ID
Password
Save Password
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Value
zeam01
ZEAM01
class
checked
Page 4 of 52
©2012 IBM Corporation
What did
I just do?
You created a set of credentials that will be used to remotely log into your CICS
region from RDz.
□ 08. On the left of the Preferences window, click on CICS ExplorerConnections.
□ 09. Under Connection, select CICS Management Interface from the dropdown menu and click New.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 5 of 52
©2012 IBM Corporation
□ 10. Enter the following values.
Field
Name
Host
Port Number
Credentials
Value
CICS-ZEAM01
wg31.washington.ibm.com
1401
zeam01
Click Apply and Connect.
If you are prompted to sign on, click OK. Your userid and password should already be filled in.
What did
I just do?
You created a connection to your CICS region using the CICS management interface.
□ 11. Under Connection, select CICS Resource Definition Server via REST from the dropdown menu
and click New.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 6 of 52
©2012 IBM Corporation
□ 12. Enter the following values.
Field
Name
Host
Port Number
Credentials
Value
REST-ZEAM01
wg31.washington.ibm.com
5130
zeam01
Click Apply and Connect.
What did
I just do?
You created a connection to your CICS region’s resource definition server using the
REST interface.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 7 of 52
©2012 IBM Corporation
□ 13. Click OK to exit the Preferences window.
□ 14. In the RDz menu bar, click on WindowOpen PerspectiveOther…
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 8 of 52
©2012 IBM Corporation
□ 15. Select Remote System Explorer and click OK.
□ 16. In the Remote Systems view, expand New Connection.
Right-click on z/OS… and select New Connection.
□ 17. In the New Connection wizard, enter wg31.washington.ibm.com for the host name.
Click Next.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 9 of 52
©2012 IBM Corporation
□ 18. Click the radio button next to Remote daemon.
The daemon port is 4035.
The authentication method is userid/password.
Click Finish.
What did
I just do?
You created a connection to your z/OS system. This will allow you to easily move
files from your workstation to your z/OS system.
PART 2: JAVA DEVELOPMENT USING RDZ
□ 19. On the Welcome page, click on the Workbench icon.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 10 of 52
©2012 IBM Corporation
□ 20. From the RDz menu bar, click on WindowPreferences.
□ 21. On the left of the Preferences window, click on Plug-in DevelopmentTarget Platform.
□ 22. In the Target Platform pane, click Add.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 11 of 52
©2012 IBM Corporation
□ 23. In the New Definition Wizard, select the Template radio button.
Select CICS TS V4.2 Runtime from the dropdown menu.
Click Next >.
□ 24. Click Finish to exit the New Definition Wizard.
□ 25. In the Preferences window, check the box next to CICS TS V4.2 Runtime.
This will set it as the default target environment.
Click OK to exit the Preferences window.
What did
I just do?
A target definition consists of a set of plug-ins and environment settings.
When you set a target definition, you ensure that you only use the plug-ins and
settings for a specific release of CICS.
In this case, we are selecting CICS V4.2 as our target definition, since this is the
version of CICS on our z/OS guest.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 12 of 52
©2012 IBM Corporation
□ 26. From the RDz menu bar, click on FileNewProject to open the New Project Wizard.
□ 27. In the New Project Wizard, click on Plug-in Project.
Click Next >.
□ 28. Specify a project name of com.ibm.ddw.simple.parsers.
In the Target Platform section, click on the radio button next to an OSGi Framework.
Select Equinox from the dropdown menu.
Click Next >.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 13 of 52
©2012 IBM Corporation
□ 29. On the Content page, change the Version from 1.0.0.qualifier to 1.0.0.
Specify a name of SimpleParsers.
Uncheck the box next to Generate an activator.
Click Finish.
□ 30. You will be asked if you would like to switch to the Plug-in Development Perspective.
Click Yes.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 14 of 52
©2012 IBM Corporation
What did
I just do?
You have just created a plug-in project.
A plug-in project corresponds to an OSGi bundle.
This particular OSGi bundle will contain utility classes used by other OSGi bundles,
which we will create later.
□ 31. In the Package Explorer view, expand com.ibm.ddw.simple.parsers.
Right-click on src.
Select NewPackage.
□ 32. Specify a name of com.ibm.ddw.simple.parsers.
Click Finish.
What did
I just do?
You have just created a Java package.
Packages are used as a way to organize Java classes. Typically, classes that belong to
the same category or have similar functionality will be grouped in a single package.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 15 of 52
©2012 IBM Corporation
□ 33. From the Windows desktop, use Explorer to navigate to C:\CICSLAB\OSGiRESTwithCWS.
You should see a number of Java-related items.
□ 34. Drag and drop the following files from Explorer to the com.ibm.ddw.simple.parsers package
that you just created.
SimpleNameValuePairParserToHashTable.java
SingleLevelJSONParserToHashTable.java
SingleLevelXmlParserToHashTable.java
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 16 of 52
©2012 IBM Corporation
When prompted, select Copy files and click OK.
What are
these files?
These utility classes are very simple parsers. They take JSON, XML, or name/value pairs and put
them into a Java hashtable.
A hashtable simply maps a key to a value, like “name” (key) = “John Smith” (value) or “phone
number” (key) = “123-456-7890” (value).
□ 35. From the Package Explorer view, expand com.ibm.ddw.simple.parsersMETA-INF.
Double-click on MANIFEST.MF.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 17 of 52
©2012 IBM Corporation
□ 36. In the Manifest Editor, click on the Runtime tab (across the bottom of the editor).
□ 37. In the Exported Packages section, click on Add.
□ 38. In the Exported Packages window, select com.ibm.ddw.simple.parsers.
Click OK.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 18 of 52
©2012 IBM Corporation
□ 39. Save and close the Manifest Editor.
What did
I just do?
You have exposed the com.ibm.ddw.simple.parsers package.
This means that all of the classes in that package are now visible to other OSGi
bundles.
□ 40. From the RDz menu bar, click FileNewProject to open the New Project Wizard.
□ 41. In the New Project Wizard, click on Plug-in Project.
Click Next >.
□ 42. Specify a project name of com.ibm.ddw.customer.maintenance.
Click Next.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 19 of 52
©2012 IBM Corporation
□ 43. On the Content page, change the Version from 1.0.0.qualifier to 1.0.0.
Specify a name of CustomerMaintenance.
Uncheck the box next to Generate an activator.
Click Finish.
□ 44. In the Package Explorer view, right-click on com.ibm.ddw.customer.maintenancesrc.
Select NewPackage.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 20 of 52
©2012 IBM Corporation
□ 45. Specify a package name of com.ibm.ddw.customer.datalayouts.
Click Finish.
□ 46. From the Windows desktop, use Explorer to navigate to C:\CICSLAB\OSGiRESTwithCWS.
Drag and drop the following files from Explorer to the com.ibm.ddw.customer.datalayouts
package that you just created.
CustProgCommarea.java
CustProgFileLayout.java
When prompted, select Copy files and click OK.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 21 of 52
©2012 IBM Corporation
Note:
There will be errors in the Java files you just imported.
This is ok for now. We will fix these errors shortly.
□ 47. In the Package Explorer view, right-click on com.ibm.ddw.customer.maintenancesrc.
Select NewPackage.
□ 48. Specify a package name of com.ibm.ddw.customer.datalayouts.
Click Finish.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 22 of 52
©2012 IBM Corporation
□ 49. From the Windows desktop, use Explorer to navigate to C:\CICSLAB\OSGiRESTwithCWS.
Drag and drop the following files from Explorer to the com.ibm.ddw.customer.maintenance
package that you just created.
CustPgmJ.java
CustProgFileHelper.java
When prompted, select Copy files and click OK.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 23 of 52
©2012 IBM Corporation
□ 50. From the Windows desktop, use Explorer to navigate to C:\CICSLAB\OSGiRESTwithCWS.
Drag and drop the following files from Explorer to the com.ibm.ddw.customer.maintenance
project (not the package).
marshall.jar
connector.jar
When prompted, select Copy files and click OK.
□ 51. In the Package Explorer view, expand com.ibm.ddw.customer.maintenanceMETA-INF.
Double-click on MANIFEST.MF.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 24 of 52
©2012 IBM Corporation
□ 52. In the manifest editor, click on the Dependencies tab (across the bottom of the editor).
□ 53. In the Imported Packages section, click the Add button.
□ 54. In the Package Selection dialog, select the following packages.
com.ibm.ddw.simple.parsers
com.ibm.cics.server (1.1300.0)
com.ibm.record (1.0.0)
Hint:
You can use the filter to find these packages instead of scrolling through the entire
list.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 25 of 52
©2012 IBM Corporation
□ 55. The list of imported packages should now look like this.
What did
I just do?
You have made these packages accessible to your OSGi bundle.
□ 56. In the Manifest Editor, click on the Runtime tab (across the bottom of the editor).
□ 57. In the Exported Packages section, click the Add button.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 26 of 52
©2012 IBM Corporation
□ 58. In the Exported Packages dialog, select both com.ibm.ddw.customer.maintenance and
com.ibm.ddw.customer.datalayouts.
Click OK.
□ 59. In the Manifest Editor (still in the Runtime tab), in the Classpath section, click the Add button.
□ 60. In the Jar Selection dialog, select both connector.jar and marshall.jar.
Check the box next to Update the build path.
Click OK.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 27 of 52
©2012 IBM Corporation
□ 61. In the manifest editor, click on the MANIFEST.MF tab (across the bottom of the editor).
□ 62. Add the following line to the bottom.
CICS-MainClass: com.ibm.ddw.customer.maintenance.CustPgmJ
There must be a blank line at the end of the file.
What did
I just do?
This line tells the OSGi framework implementation in CICS to include the CustPgmJ
class as a “service”.
This class has a main() method that CICS will invoke. This service is referenced on a
CICS PROGRAM definition.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 28 of 52
©2012 IBM Corporation
□ 63. Save the manifest by pressing CTRL-s or clicking on the save icon.
Close the Manifest Editor.
□ 64. From the RDz menu bar, click FileNewProject to open the New Project Wizard.
□ 65. In the New Project Wizard, click on Plug-in Project.
Click Next >.
□ 66. Specify a project name of com.ibm.ddw.customer.rest.
Click Next >.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 29 of 52
©2012 IBM Corporation
□ 67. On the Content page, change the Version from 1.0.0.qualifier to 1.0.0.
Specify a name of CustomerRest.
Uncheck the box next to Generate an activator.
Click Finish.
□ 68. In the Package Explorer view, right-click on com.ibm.ddw.customer.restsrc.
Select NewPackage.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 30 of 52
©2012 IBM Corporation
□ 69. Specify a package name of com.ibm.ddw.customer.datalayouts.
Click Finish.
From the Windows desktop, use Explorer to navigate to C:\CICSLAB\OSGiRESTwithCWS.
Drag and drop the following file from Explorer to the com.ibm.ddw.customer.rest package you
just created.
CustResJ.java
When prompted, select Copy files and click OK.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 31 of 52
©2012 IBM Corporation
□ 70. In the Package Explorer view, expand com.ibm.ddw.customer.restMETA-INF.
Double-click on MANIFEST.MF.
□ 71. In the Manifest Editor, click on the Runtime tab (across the bottom of the editor).
□ 72. In the Exported Packages section, click on the Add button.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 32 of 52
©2012 IBM Corporation
□ 73. In the Exported Packages dialog, select com.ibm.ddw.customer.rest.
Click OK.
□ 74. In the Manifest Editor, click on the Dependencies tab (across the bottom of the editor).
□ 75. In the Imported Packages section, click the Add button.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 33 of 52
©2012 IBM Corporation
□ 76. In the Package Selection dialog, select the following packages.
com.ibm.ddw.customer.datalayouts
com.ibm.ddw.customer.maintenance
com.ibm.cics.server (1.1300.0)
com.ibm.record (1.0.0)
Hint:
You can use the filter to find these packages instead of scrolling through the entire
list.
□ 77. The list of imported packages should now look like this.
□ 78. In the manifest editor, click on the MANIFEST.MF tab (across the bottom of the editor).
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 34 of 52
©2012 IBM Corporation
□ 79. Add the following line to the bottom.
CICS-MainClass: com.ibm.ddw.customer.rest.CustResJ
There must be a blank line at the end of the file.
□ 80. Save the manifest by pressing CTRL-s or clicking on the save icon.
Close the Manifest Editor.
□ 81. From the RDz menu bar, click FileNewProject to open the New Project Wizard.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 35 of 52
©2012 IBM Corporation
□ 82. Select CICS ResourcesCICS Bundle project.
Click Next >.
□ 83. Specify a project name of BUNDLE-RestCustomerApp.
Click Finish.
□ 84. In the Package Explorer view, right-click on the BUNDLE-RestCustomerApp project.
Select NewOther.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 36 of 52
©2012 IBM Corporation
□ 85. Select CICS ResourcesInclude OSGi Project in Bundle.
Click Next >.
□ 86. Select the com.ibm.ddw.customer.maintenance project to be included in the bundle.
Specify a JVM Server name of JVMSRV01.
Click Finish.
□ 87. Repeat the steps above to add the following projects to the bundle.
com.ibm.ddw.customer.rest
com.ibm.ddw.simple.parsers
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 37 of 52
©2012 IBM Corporation
Specify a JVM Server name of JVMSRV01 for both of these projects.
□ 88. In the Package Explorer, expand BUNDLE-RestCustomerAppMETA-INF.
Double-click on cics.xml.
In the Manifest Editory, you should see three deployable resources.
What did
I just do?
You created a CICS Bundle project that corresponds to a CICS BUNDLE.
Then you added your OSGi bundles to the CICS bundle. A CICS bundle is the
smallest grouping of Java classes that can be deployed to CICS.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 38 of 52
©2012 IBM Corporation
PART 3: DEPLOYING THE CICS BUNDLE TO Z/OS
□ 89. In the Package Explorer view, right-click on BUNDLE-RestCustomerApp.
Select Deploy CICS Bundle.
Note:
The context menu in the screenshot has been altered to conserve space.
The Deploy CICS Bundle option will not be in the same location in RDz.
□ 90. In the Deploy CICS Bundle dialog, check the box next to Deploy bundle archive to remote
system.
In the z/OS UNIX connection dropdown box, select wg31.washington.ibm.com.
Specify a Bundle container of /u/zeam01/cicslab/bundles
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 39 of 52
©2012 IBM Corporation
Check the boxes next to Save resource definition… and Install BUNDLE resource…
Click Configure.
In the Preferences dialog, specify a Type of CICS Resource Definition Server via REST.
From the Name dropdown box, select REST-ZEAM01.
Click the Connect button.
Click OK to dismiss the Preferences dialog.
Back in the Deploy CICS Bundle dialog, in the CICS System or Region dropdown box, select
CICS42.
Click Finish to start the deploy process.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 40 of 52
©2012 IBM Corporation
If you are prompted for a userid and password, use zeam01 / class.
If you are given an SSL warning, click Yes.
If you are prompted to set the file encoding of the CICS bundle to UTF-8, click Yes.
□ 91. Once the CICS bundle has been deployed, in the RDz menu bar, click on WindowOpen
PerspectiveOther…
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 41 of 52
©2012 IBM Corporation
□ 92. Select CICS SM.
Click OK.
□ 93. In the RDz menu bar, click on WindowPreferences.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 42 of 52
©2012 IBM Corporation
□ 94. In the Preferences dialog, select CICS ExplorerConnections.
Under Connection, specify a Type of CICS Management Interface.
In the Name dropdown box, select CICS-ZEAM01.
Click Connect.
Click OK to dismiss the Preferences dialog.
□ 95. In the RDz menu bar, click on OperationsBundles.
□ 96. In the Bundles view, you should see the BUNDLE-R bundle enabled.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 43 of 52
©2012 IBM Corporation
□ 97. In the RDz menu bar, click on OperationsJavaOSGi Services.
□ 98. In the OSGi Services view, you should see two services.
□ 99. In the RDz menu bar, click on OperationsJavaOSGi Bundles.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 44 of 52
©2012 IBM Corporation
IN THE OSGI BUNDLES VIEW , YOU SHOULD SEE THREE BUNDLES.
PART 4: TESTING THE APPLICATION
Note:
In order to test the application, there are some resources that need to be defined in
CICS.
We have already defined the following resources in CICS for you.
TCPIPService definition – tells CICS to listen on a specified port
URIMAP – tells CICS that incoming HTTP REST requests should invoke your Java
program
FILE – because the Java program uses a VSAM file
PROGRAMs – for backend data logic, the CUSTDATA file load, and the REST interface
□ 100. Start the Firefox browser.
There should be an icon on your desktop for Firefox.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 45 of 52
©2012 IBM Corporation
□ 101. Specify the following URL:
http://wg31.washington.ibm.com:9001/customer/address/00000001
You should see customer information in XML format.
□ 102. Change the customer number to 23 and try again.
http://wg31.washington.ibm.com:9001/customer/address/00000023
You should receive an error since this customer number does not exist.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 46 of 52
©2012 IBM Corporation
□ 103. From the Firefox menu bar, click on ToolsPoster.
□ 104. In the Poster dialog, specify the following URL:
http://wg31.washington.ibm.com:9001/customer/address/00000001
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 47 of 52
©2012 IBM Corporation
□ 105. You should receive the customer information in XML format.
Click Close.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 48 of 52
©2012 IBM Corporation
□ 106. In the Poster dialog, specify the following URL:
http://wg31.washington.ibm.com:9001/customer/address/00000009
Specify the Content Type of text/xml.
Enter the following in the content section:
<address><firstName>Pink</firstName><lastName>Panther</lastName></address>
Click on the POST button.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 49 of 52
©2012 IBM Corporation
□ 107. You should see an HTTP 201 status code indicating the customer record was successfully
created.
Click Close.
□ 108. In the Poster dialog, click the POST button again (without changing anything).
You should receive an error indicating the customer record already exists.
Click Close.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 50 of 52
©2012 IBM Corporation
□ 109. In the Poster dialog, specify the following URL:
http://wg31.washington.ibm.com:9001/customer/address/00000008
Specify the Content Type of text/json.
Enter the following in the content section:
{“firstName”:”Pink”,”lastName”:”Panther”}
Click on the POST button.
□ 110. You should see an HTTP 201 status code indicating the customer record was successfully
created.
Click Close.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 51 of 52
©2012 IBM Corporation
□ 111. Congratulations! You have completed this lab.
z/OS Java Exploiters and Java Batch
Lab 7b: RESTful Service in CICS
Last Updated: 2012-04-19
Page 52 of 52
©2012 IBM Corporation
IBM Wildfire Series
z/OS Java Exploiters and Java Batch
Unit 8: Java Support in DB2 UDB for z/OS
WSC Wildfire Class
© 2012 IBM Corporation
IBM Wildfire Series
Database Connection from Java - Techniques
 JDBC – dynamic SQL support
– Code JDBC methods in a Java program
– Compile with javac command
– Uses the JDBC Universal Driver for DB2 for z/OS
Two modes of operation
•
•
Type-2 JDBC Driver – Uses JNI to connect to DB2 (fastest)
Type-4 JDBC Driver – Pure Java Driver using TCP/IP to connect to DB2
 SQLJ – static SQL support
– Code SQL in a Java program, then translate and compile with the sqlj
command
– Run the db2sqljcustomize command from the z/OS UNIX System Services
command line to customize the serialize profiles and bind DB2 packages.
 Because SQLJ can interoperate with JDBC, an application program can use
JDBC and SQLJ within the same unit of work.
2
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Making Java routines available to DB2 programmers
 Stored Procedures
– Invoked from Client Program by executing an SQL CALL
Statement
– The stored procedure then performs the database access
work and returns results to the calling program
 User Defined Functions (UDFs)
– Invoked by specifying UDF name followed by its arguments
in an SQL statement
– DB2 Java UDFs let you extend the functionality of the
database server SQL language
3
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Stored Procedure Compared to Separate JDBC Calls
The Universal JDBC Driver provides the ability to batch SQL statements together in a single call.
This can reduce network trips if there is no requirement for business logic between calls.
Separate Calls
Stored Procedure
Select
DB2
DB2
PROCA
PROCA
Java
Java Client
Client Update
Insert
4
© 2012 IBM Corporation
DB2
DB2
Java
Java Client
Client
Call
PROCA
Perform
PerformSQL
SQL
Perform
PerformSQL
SQL
Commit
Commit
© 2003 IBM Corporation
IBM Wildfire Series
Prerequisites for running Java Stored Procedures
– DB2 UDB V7 for z/OS or Above
– USS, RRS and WLM
– IBM Java for z/OS
• Java 1.3.1 or 1.4.2. Both 31 bit and 64 bit JVMs are supported.
• PQ76769 Is required for DB2 V7 to Support SDK 1.4.2
• Java 1.5 (Java V5) is supported with DB2 V8 by installing the PTF
for APAR PK09213. Both 31 and 64 bit JVMs are supported.
• Java 1.5 (Java V5) is supported with DB2 V9. Both 31 and 64 bit
JVMs are supported.
5
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Development tools for Java Stored Procedures
 DB2 Data Studio (IDE package version required for Java development)
– Eclipse based
– Compatible with DB2 for z/OS V8 and V9
– Free download from:
http://www.ibm.com/developerworks/downloads/im/data/index.html
– Free ebook from:
http://www.ibm.com/developerworks/wikis/display/db2oncampus/FREE+ebook
+-+Getting+started+with+IBM+Data+Studio+for+DB2
 DB2 Development Center
– Introduced with DB2 V8
– Create, build, and deploy Java(TM) and SQL stored procedures
– Create, build, and deploy user-defined functions
 Rational Application Developer V7
– RAD contains a subset of the technology in DB2 Development Center
 Code by hand
– That’s what we’ll do in this class
6
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
A simple Stored Procedure written in Java
// This is a sample Stored Procedure. It executes an SQL Query
// that returns a result set. The result set is then returned
// unmodified to the calling program.
import java.util.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import com.ibm.db2.jcc.*;
public class spTest {
public static void doIt(ResultSet[] TableName) {
try{
System.out.println("*** spTest running at " + new java.util.Date() + " ***");
7
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
A simple Stored Procedure written in Java (continued)
DB2SimpleDataSource db2ds = new DB2SimpleDataSource();
// There is no need to specify a databaseName because this is a
// Stored Procedure, so the target location is already established.
Connection conn = db2ds.getConnection();
Statement stmt = conn.createStatement();
System.out.println("*** JDBC Statement Created ***");
// Execute a Query and generate a ResultSet instance
// The Query is a Select from SYSIBM.SYSDATABASE
TableName[0] = stmt.executeQuery("SELECT * FROM SYSIBM.SYSDATABASE");
System.out.println("*** JDBC Result Set Created ***");
} catch (Exception e) {
e.printStackTrace();}
System.out.println("*** spTest Ended ***");
} /* End method doIt */
} /* End class spTest */
8
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
A simple User Defined Function written in Java
import java.sql.*;
import java.lang.*;
import COM.ibm.db2.app.*;
class myUDF extends UDF {
public static int testUDF(int edlev) {
To select only records with an “edlevel” of 18 or
greater:
try
{
if (edlev < 14)
return(1);
if (edlev < 18)
SELECT * FROM DSN8810.EMP WHERE
FUNCTEST(EDLEVEL)=3
return(2);
return(3);
}
catch (Exception e)
{
return(0);
}
}
} // End of Sample UDF
9
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
WLM Application Environment (member name WLMZM01)
//DSN8ENV PROC RGN=0K,APPLENV=DSN9ENV,DB2SSN=DSN9,NUMTCB=5
//IEFPROC EXEC PGM=DSNX9WLM,REGION=&RGN,TIME=NOLIMIT,
//
PARM='&DB2SSN,&NUMTCB,&APPLENV'
//STEPLIB DD DISP=SHR,DSN=DSN810.RUNLIB.LOAD
//
DD DISP=SHR,DSN=SYS1.LEMVS.SCEERUN
//
DD DISP=SHR,DSN=DSN910.SDSNEXIT
//
DD DISP=SHR,DSN=DSN910.SDSNLOAD
//
DD DISP=SHR,DSN=DSN910.SDSNLOD2
//SYSEXEC DD DISP=SHR,DSN=DSN910.SDSNCLST
//SYSTSPRT DD SYSOUT=*
//JAVAENV DD DSN=ZEAM01.#V0.JAVAENV,DISP=SHR
//JAVAOUT DD PATH='/u/zeam01/javaout.txt',
//
PATHOPTS=(ORDWR,OCREAT,OAPPEND),
//
PATHMODE=(SIRUSR,SIWUSR,SIRGRP,SIWGRP,SIROTH,SIWOTH)
//JAVAERR DD PATH='/u/zeam01/javaerr.txt',
//
PATHOPTS=(ORDWR,OCREAT,OAPPEND),
//
PATHMODE=(SIRUSR,SIWUSR,SIRGRP,SIWGRP,SIROTH,SIWOTH)
//CEEDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSABEND DD DUMMY
NUMTCB = number of JVMs to run (use about 5 to 8 for production)
10
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Java Environment Variables in ZEAMXX.#V0.JAVAENV
ENVAR("CLASSPATH=/u/zeam01/classes",
"JCC_HOME=/shared/db2910_jdbc",
“DB2_BASE=/shared/db2910_base”,
"JAVA_HOME=/usr/lpp/java/J5.0",
"JVMPROPS=/u/zeam01/jvmprops"),
MSGFILE(JSPDEBUG),
XPLINK(ON)
11
–
CLASSPATH – Directory containing JAVA Routines
–
JCC_HOME – Directory containing JDBC/SQLJ Driver
–
DB2_BASE – Directory containing stored procedure support jar file
–
JAVA_HOME – Directory containing JAVA SDK
–
JVMPROPS – File containing JVM properties
–
WORK_DIR – If JAVAOUT DD or JAVAERR DD are not specified, then stdout and stderr go to the
WORK_DIR directory.
–
MSGFILE – DD Name for LE Runtime diagnostics
–
XPLINK(ON) – Enables Extra Performance Linkage support, which improves subroutine call and
return performance. Should always be enabled nowadays.
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Commands Used in Preparation Processes
 javac
– Run from omvs or other Unix shell
– Compiles the stored procedure to create a .class file
 sqlj
– Used only for SQLJ programs
– Run from omvs or other Unix shell
– Creates modified Java source file and customized serial profile
 CREATE PROCEDURE
– Run from SPUFI or batch job
– Defines stored procedure to DB2
 CREATE FUNCTION
– Run from SPUFI or batch job
– Defines user defined function to DB2
12
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Deploying Java Routines to DB2
Defining a Java Stored Procedure to DB2
– CREATE PROCEDURE statement defines a Stored Procedure to DB2
– Example:
CREATE PROCEDURE LOOKUPBN(INTEGER) Stored Procedure Nam
EXTERNAL NAME ‘lookUp.byNumber’
Classname.MethodName
LANGUAGE JAVA
PARAMETER STYLE JAVA
COLLID DEPT1
PROGRAM TYPE SUB
DYNAMIC RESULT SETS 1
WLM ENVIRONMENT WLMJAVA;
– See DB2 SQL Reference for details on use of CREATE
13
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Deploying Java Routines to DB2
Defining a Java User Defined Function
– CREATE FUNCTION statement defines a UDF to DB2:
– Example:
CREATE FUNCTION GETMAX(value1 INT)
EXTERNAL NAME ‘Evaluator.getHighest’ classname.methodname
RETURNS INTEGER
 Type of data returned
FENCED
VARIANT
NO SQL
LANGUAGE JAVA
PARAMETER STYLE JAVA
COLLID DEPT84
WLM ENVIRONMENT WLMJAVA;
– See DB2 SQL Reference for details on use of CREATE
14
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
References
www.redbooks.ibm.com
DB2 for z/OS Stored Procedures: Through the CALL and
Beyond
– SG24-7083-00
 DB2 UDB for OS/390 and z/OS V8 Application Programming
Guide and Reference for Java(TM)
– SC18-7414-04
 DB2 UDB for OS/390 and z/OS V9 Application Programming
Guide and Reference for Java(TM)
– SC18-9842-09
15
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
z/OS Java Exploiters and Java Batch
Lab 8: Java and DB2
WSC Wildfire Class
© 2012 IBM Corporation
IBM Wildfire Series
Lab 8: Implementing Java Stored Procedures and
Java User Defined Functions in DB2
 Setup of environment needed to install and run stored
procedures
 Create, install, and execute a Java stored procedure
– Stored Procedure will be invoked by separate Java program that
is provided
– Expected output is a list of names from SYSIBM.SYSDATABASE
 Create, install, and execute a User Defined Function that is
written in Java
– User Defined Function will be referenced by a very simple SQL
program invoked from within SPUFI
– Expected output is a simple report
17
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM – Java – z/Series Seminars
Lab 8: Implementing Java Stored Procedures and
Java User Defined Functions in DB2 V9
Version of November 29, 2012
© Copyright 2012 International Business Machines Corporation
IBM – Java – z/Series Seminars
Lab: Implementing Java Stored Procedures and
Java User Defined Functions in DB2
Approximate time for completion:
The anticipated typical time for completion is 45 to 60 minutes, but varies depending
upon the student’s level of familiarity with Unix System Services, DB2, and Java.
This lab exercise will help you learn how to configure a z/OS system to run Java stored
procedures and Java user defined functions (UDFs). In addition, you will learn how to
install, execute, and modify Java stored procedures and Java user defined functions.
The final products of this lab exercise will be (1) a report generated by invoking a Java
Stored Procedure and (2) a report generated by running an SQL query that uses a Java
User Defined Function.
Java code in a stored procedure can be executed on a zAAP processor, which has the
potential of reducing overall computing cost. In contrast, a stored procedure written in
COBOL must execute on a relatively expensive general processor.
This lab uses the Universal JDBC Driver for z/OS, which is a combination Type-2 / Type4 driver. The driver automatically selects the mode of operation based on the format of
the JDBC URL that is passed to the driver.
Lab Prerequisites
IBM Redbook DB2 for z/OS Stored Procedures: Through the CALL and Beyond – March
2008, SG24-7604, chapter 13 (referred to as “Redbook” in the instructions below)
Access to DB2 UDB for z/OS V9 Codes, GC18-9843, available at:
http://www-01.ibm.com/support/docview.wss?uid=swg27011656
IBM z/Series system running z/OS V8 or later; DB2 V9; Java V5
Access to TSO and Unix Systems Services.
Lab Overview
There are three phases in this lab. The first phase covers setup of the environment
needed to develop and run stored procedures.
The second phase of the lab gives you an opportunity to create, install, and execute a
stored procedure. A very simple sample stored procedure is provided. Depending on
your level of Java and JDBC knowledge, you can modify the sample stored procedure to
perform additional functions.
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 2 of 19
IBM – Java – z/Series Seminars
The third phase of the lab gives you an opportunity to create, install, and execute a user
defined function that is written in Java. Creating and installing a user defined function is
similar to creating and installing a stored procedure. After creating and installing a
stored procedure, you should find it easy to work with user defined functions.
These lab instructions require you to write the answers to various questions about your
system environment. The answers that you write are used in subsequent steps in the
lab, so it is important that you write the answers in the spaces provided.
Lab Steps
IMPORTANT: When logging on to TSO, specify IKJACCNT in the Procedure field
and DB2910 in the Command field.
Phase 1 – Environmental Setup
____ 1. Ensure that you have Redbook SG24-7604, chapter 13. It is possible to complete this
lab without using the Redbook, but we suggest that you refer to the Redbook where
indicated to gain a more in-depth understanding of the topic.
____ 2. Verify that the system has the appropriate release of z/OS and DB2. To display the
release of z/OS, go to ISPF and issue D.LOG to access the console, then issue /D
IPLINFO to display the release of z/OS. To determine the release of DB2, ask the DB2
administrator.
____ 3. The system has multiple versions of the Java SDK installed, but you will use the Java
V5 SDK for this lab. Java V5 is also known as Java 1.5.
Ensure that your .profile is set so that you use Java V5 for this lab by uncommenting
the export JAVA_HOME statement in your /u/zeam01/.profile file that points to Java
V5. Be sure to comment out any other export JAVA_HOME statements in your
.profile.
____ 4. Write the pathname of the Java V5 directory on the line below.
__________________________________________________________
____ 5. To cause any changes in your .profile to become effective, issue the exit command to
exit out of the OMVS shell and then return to OMVS by entering omvs at a TSO
command line.
____ 6. To determine the release of Java that is installed and defined in your .profile, issue the
following command at the OMVS shell command line:
java -version
Which specific release of Java V5 is installed on the z/OS system and defined in your
.profile?
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 3 of 19
IBM – Java – z/Series Seminars
__________________________________________________________
____ 7. Verify the location of the DB2 JDBC library. The Universal JDBC driver location is
/shared/db2910_jdbc. The classes are in /shared/db2910_jdbc/classes and the load
modules (used only when running in Type-2 mode) are in /shared/db2910_jdbc/lib.
Various utility programs are in /shared/db2910_jdbc/bin.
____ 8. Verify that that DB2 subsystem is running by looking for the following jobs in SDSF.
(Issue =D.DA from ISPF):
DSN9DBM1
DSN9DIST
DSN9IRLM
DSN9MSTR
____ 9. If the DB2 subsystem is not running, start DB2 by issuing the following operator
command from SDSF (=D.LOG from ISPF):
/-dsn9 start db2
____ 10. The build level of the Universal JDBC Driver may be determined by
issuing the db2jcc command from the OMVS command line.
Note: The file /shared/db2910_jdbc/classes/db2jcc.jar must be in your
CLASSPATH to run the db2jcc command. You can issue the command set from an
OMVS command line to view the setting of the CLASSPATH environment variable.
Change your current directory to /shared/db2910_jdbc/bin. Then run the db2jcc
command as shown below.
db2jcc
–version
or, for much more detailed information, including information about the Java and z/OS
environment:
db2jcc
–configuration
What is the JDBC Universal Driver Architecture level of the Universal JDBC Driver on
the lab system?
__________________________________________________________
____ 11. Workload Manager application environment definitions have already been
created for your zeam’s WLM proc by using the WLM utility. (Please do not try to run
the WLM utility on the lab system because you could potentially destroy the lab
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 4 of 19
IBM – Java – z/Series Seminars
environment.) Therefore, you do not need to add any WLM application environment
definitions. (On a customer system, the systems programmer would create a WLM
application environment definition for each WLM proc.)
The sample WLM JCL proc for running stored procedures on the lab system is
ZEAM01.JCL.CNTL(WLMZM01). Copy the WLMZM01 member to the lab proclib,
SYSU.USER.PROCLIB.
What is the member name for your zeam’s WLM proc?
__________________________________________________________
Use the ISPF editor to edit your zeam’s WLM proc in SYSU.USER.PROCLIB. Verify
(and change, if needed) the following DDs to point to your zeam’s libraries as follows:
JAVAENV DD should point to ZEAM01.#V0.JAVAENV
JAVAOUT DD should point to /u/zeam01/javaout.txt
JAVAERR DD should point to /u/zeam01/javaerr.txt
The section of the WLMZM01 member that you might need to modify is shown below
in blue.
//*
JCL FOR RUNNING THE WLM-ESTABLISHED JAVA STORED PROCEDURES
//*
ADDRESS SPACE.
//*
RGN
-- THE MVS REGION SIZE FOR THE ADDRESS SPACE.
//*
DB2SSN -- THE DB2 SUBSYSTEM NAME-GROUP NAME IF DATASHARING
//*
NUMTCB -- THE NUMBER OF TCBS USED TO PROCESS
//*
END USER REQUESTS.
//*
APPLENV -- THE MVS WLM APPLICATION ENVIRONMENT
//*
SUPPORTED BY THIS JCL PROCEDURE.
//*
//*************************************************************
//DSN9ENV PROC RGN=0K,APPLENV=DSN9ENV,DB2SSN=DSN9,NUMTCB=2
//IEFPROC EXEC PGM=DSNX9WLM,REGION=&RGN,TIME=NOLIMIT,
//
PARM='&DB2SSN,&NUMTCB,&APPLENV'
//STEPLIB DD DISP=SHR,DSN=DSN910.RUNLIB.LOAD
//
DD DISP=SHR,DSN=SYS1.LEMVS.SCEERUN
//
DD DISP=SHR,DSN=DSN910.SDSNLOAD
//
DD DISP=SHR,DSN=DSN910.SDSNLOD2
//
DD DISP=SHR,DSN=DSN910.SDSNEXIT
//*
DD DSN=SYS1.CPP.SCBCCMP,DISP=SHR
//SYSEXEC DD DISP=SHR,
<== LOCATION OF DSNTPSMP
//
DSN=DSN910.#V0.SDSNCLST
//SYSTSPRT DD SYSOUT=*
//JAVAENV DD DSN=ZEAMtt.#V0.JAVAENV,DISP=SHR
//JAVAOUT DD PATH='/u/zeamtt/javaout.txt',
//
PATHOPTS=(ORDWR,OCREAT,OAPPEND),
//
PATHMODE=(SIRUSR,SIWUSR,SIRGRP,SIWGRP,SIROTH,SIWOTH)
//JAVAERR DD PATH='/u/zeamtt/javaerr.txt',
//
PATHOPTS=(ORDWR,OCREAT,OAPPEND),
//
PATHMODE=(SIRUSR,SIWUSR,SIRGRP,SIWGRP,SIROTH,SIWOTH)
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 5 of 19
IBM – Java – z/Series Seminars
//CEEDUMP
//SYSPRINT
//SYSABEND
//DSNTRACE
//*
DD
DD
DD
DD
SYSOUT=*
SYSOUT=*
DUMMY
SYSOUT=*
____ 12. Next, you will create the JAVAENV dataset, which describes the JVM
environment settings, such as the CLASSPATH. Use ISPF option =3.2 to create a
sequential dataset named ‘ZEAM01.#V0.JAVAENV’. Specify record format VB and
record length 255. The dataset will contain only a few lines of data, so 1 track is
sufficient.
IMPORTANT: The JAVAENV dataset must be Record Format=VB and Record
length=255.
Read Redbook section 13.3.8 to see a description of the settings in the JAVAENV
dataset when using the Universal JDBC Driver.
____ 13. Use the ISPF editor to edit the ZEAM01.#V0.JAVAENV dataset.
Carefully enter the information below into the dataset.
ENVAR("CLASSPATH=/u/zeam01/db2sp/classes",
"JVMPROPS=/u/zeam01/db2sp/jvmprops",
"DB2_BASE=/shared/db2910_base",
"JCC_HOME=/shared/db2910_jdbc",
"JAVA_HOME=/shared/java/J5.0",
"WORK_DIR=/tmp"),
MSGFILE(JSPDEBUG),
XPLINK(ON)
____ 14. Based on the CLASSPATH specified in your ZEAM01.#V0.JAVAENV
dataset, in which directory will your zeam’s Java stored procedure class files be
located?
________________________________________________________
____ 15. Based on the JCC_HOME specified in your ZEAM01.#V0.JAVAENV
dataset, in which directory is the Java product that will be used to run the Java stored
procedures?
________________________________________________
____ 16. Using the OEDIT editor, review the contents of the
/u/zeam01/db2sp/jvmprops file. Do not make any changes to the jvmprops file, as
the settings are acceptable for this lab exercise. Read the description of the jvmprops
file on page 190 of the Redbook, under the heading JVMPROPS (near the bottom of
page 190).
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 6 of 19
IBM – Java – z/Series Seminars
The sample jvmprops file is shown below. In a production situation, you might need to
uncomment and change one or more of the parameters, but the default valules of the
JVM properties are acceptable for this lab, so no changes are needed for the lab
exercise.
# Properties file for JVM that runs stored procedures
#-Xms128M
#-Xmx256M
#-Xinitacsh512K
#-Xinitsh512K
#-Xinitth32M
____ 17. Edit your .profile file (in /u/zeam01) and verify that the CLASSPATH and
LIBPATH are set to include the Universal JDBC driver libraries. (You determined the
pathname of the Universal JDBC driver directory in step 7, above.) Also verify that the
STEPLIB environment variables are set to include the DB2 libraries,
DSN910.#V0.SDSNEXIT, DSN910.SDSNLOD2, and DSN910.SDSNLOAD. Make
changes to your .profile if needed.
____ 18. Next, you will bind the packages for the Universal JDBC Driver. Read
Redbook section 13.3.9 for information about binding the packages.
On a customer system, only the DB2 administrator would normally have the authority
and responsibility for performing this step. This step must be performed for your
zeam’s database COLLECTION.
Since the command to bind the packages for Universal JDBC Driver is very long, it is
helpful to create a simple shell script to issue the command. A sample script file may
be found in /u/zeam01/db2sp/bind.sh.
In the bind.sh file, you will find the command to bind the packages. It will appear
similar to the example shown below. (The backslash (\) indicates that a line is being
continued to the next line.)
java com.ibm.db2.jcc.DB2Binder \
-url jdbc:db2://wg31.washington.ibm.com:9446/WG31DB2
-user zeam01 -password pwpwpw \
-collection ZEAM01
\
Edit your bind.sh file and change the –user and the –password parameters to your
zeam’s userid and password. Change the -collection parameter to your zeam’s
name, such as ZEAM01. (In a USS shell script, lines are continued by ending them
with a backslash.)
What is your zeam’s COLLECTION ID?
_______________________________________________________
From an OMVS command line, execute your customized bind.sh shell script (by
simply issuing bind.sh at the OMVS command line) to bind the DB2 Universal JDBC
Driver packages. The correct result from running the bind.sh shell script will be a list
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 7 of 19
IBM – Java – z/Series Seminars
of packages with the phrase Bind succeeded for each package.
THE MESSAGE BIND SUCCEEDED MUST BE DISPLAYED BEFORE YOU CAN
PROCEED.
REPEAT: THE MESSAGE BIND SUCCEEDED MUST BE DISPLAYED BEFORE
YOU CAN PROCEED.
If you do not see the list of packages and Bind succeeded messages after running
the bind.sh script, then the bind was not successful. Correct any errors in the bind.sh
script file and rerun the bind.sh script until the binds are successful.
____ 19. Verification and configuration of the DB2, Java, and z/OS environment is
now complete. Your z/OS system is now capable of running stored procedures that
are written in Java. You have completed the first phase of the lab.
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 8 of 19
IBM – Java – z/Series Seminars
Phase 2 – Installation and use of a Java Stored Procedure
____ 20. In the second phase of this lab, you will install and execute a stored
procedure. You will be using the following two Java programs in this phase of the lab:
 spTest.java - This program is the Java stored procedure.
 spInvoke.java - This program invokes the stored procedure. It could
be written in any of several languages, but since you are probably
familiar with Java, we are using a Java program to invoke the Java
stored procedure.
____ 21.
Both of the Java programs can be found in /u/zeam01/db2sp/classes.
____ 22. Using OEDIT, edit /u/zeam01/.profile. Add the
/u/zeam01/db2sp/classes directory to the CLASSPATH. Exit and reenter the OMVS
shell so that the changes in your .profile file take effect for your session. For example,
you would add a line similar to the following after the existing CLASSPATH
statements.
export CLASSPATH=$CLASSPATH:/u/zeam01/db2sp/classes
____ 23. Use the Unix cd command to set your current directory to
/u/zeam01/db2sp/classes.
____ 24. Using OEDIT, edit the spInvoke.java source file. Change the “tt” values
in the parameters in the following statements so that your zeam number is used:
 Db2ds.setUser(ZEAM01);
// (specify your zeam’s userid)
 Db2ds.setPassword(pwpwpw); // (specify your zeam’s password)
 CallableStatement cs = con.prepareCall(“call ZEAM01.SPTEST01()”);
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 9 of 19
IBM – Java – z/Series Seminars
For future reference, source listings for spInvoke.java and spTest.java are below.
SpInvoke.java
//
//
//
//
This simple Java main program invokes a stored procedure that
returns a result set. The contents of the returned result set
are then sent to System.out, which is normally the user’s
STDOUT workstation display.
import java.sql*;
import com.ibm.db2.jcc.*;
public class spInvoke {
public static void main(String args[])
{
DB2SimpleDataSource db2ds = new DB2SimpleDataSource();
db2ds.setDatabaseName("WG31DB2");
db2ds.setDescription("Our Database");
db2ds.setUser("ZEAM01");
db2ds.setPassword("pwpwpw");
ResultSet rs;
String s;
try
{
Connection con = db2ds.getConnection();
// SPTESTtt must match the name of the DB2 stored procedure.
// In other words, SPTESTtt must match the PROCEDURE NAME
// defined in the CREATE PROCEDURE statement in the DDL.
CallableStatement cs=con.prepareCall("call
ZEAM01.SPTEST01()");
rs = cs.executeQuery();
// Print all of the table names to sysout
while (rs.next()) {
s = rs.getString(1);
System.out.println("Table NAME = " + s);
}
con.close();
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 10 of 19
IBM – Java – z/Series Seminars
spTest.java
// This is a sample Stored Procedure. It executes an SQL Query
// that returns a result set. The result set is then returned
// unmodified to the calling program.
import
import
import
import
import
java.util.*;
java.io.IOException;
java.io.PrintWriter;
java.sql.*;
com.ibm.db2.jcc.*;
public class spTest {
public static void doIt(ResultSet[] TableName) {
try{
System.out.println("*** spTest running at " +
new java.util.Date() + " ***");
DB2SimpleDataSource db2ds = new DB2SimpleDataSource();
// There is no need to specify a databaseName because this is a
// Stored Procedure, so the target location is already
// established.
Connection conn = db2ds.getConnection();
Statement stmt = conn.createStatement();
System.out.println("*** JDBC Statement Created ***");
// Execute a Query and generate a ResultSet instance
// The Query is a Select from SYSIBM.SYSDATABASE
TableName[0] = stmt.executeQuery
("SELECT * FROM SYSIBM.SYSDATABASE");
System.out.println("*** JDBC Result Set Created ***");
} catch (Exception e) {
e.printStackTrace();}
System.out.println("*** spTest Ended ***");
}
}
____ 25.
example:
Compile spTest.java and spInvoke.java by using the Java compiler. For
javac spTest.java
javac spInvoke.java
Messages are displayed when there are compilation errors. A successful compilation
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 11 of 19
IBM – Java – z/Series Seminars
results in no messages. A .class file will be created that corresponds to each of the
source members.
The most frequent cause of compilation errors is missing or incorrect values in the
CLASSPATH. Ensure that the CLASSPATH has been configured as discussed in step
16, above.
____ 26. The stored procedure, spTest, must be defined to DB2 in order for DB2
to recognize it as a stored procedure. To define spTest, you will use the DB2 SPUFI
utility to execute several DB2 DDL commands. (Don’t start SPUFI yet.)
A member containing sample DDL is contained in ZEAM01.JCL.CNTL(SPTEST). Do
not make any changes to your newly created SPTEST member yet.
____ 27. Read Redbook section 13.8 to become familiar with the DDL parameters
for Java stored procedures. Table 13-5 on page 206 is particularly informative.
____ 28.
prompt.
Start the DB2 PRIMARY OPTION MENU by entering DB2 at the ISPF
____ 29. Select Option D, DB2I DEFAULTS. Ensure that parameter 1, DB2
NAME, is set to DSN9. Press Enter two times to execute the change and return to
the DB2 PRIMARY OPTION MENU.
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 12 of 19
IBM – Java – z/Series Seminars
____ 30. Start SPUFI by selecting option 1, SPUFI. (If a message indicating a
CCSID mismatch is displayed while using SPUFI, simply press the Enter key again
and disregard the message.)
____ 31.
Fill in the form as shown below.
SPUFI
SSID:
DSN8
===>
Enter the input data set name:
(Can be sequential or
partitioned)
1 DATA SET NAME ... ===> JCL.CNTL(SPTEST)
2 VOLUME SERIAL ... ===>
(Enter if not cataloged)
3 DATA SET PASSWORD ===>
(Enter if password protected)
Enter the output data set name:
(Must be a sequential data set)
4 DATA SET NAME ... ===> SPTEST.OUT
Specify processing options:
5 CHANGE DEFAULTS
===> YES
panel?)
6 EDIT INPUT ...... ===> YES
7 EXECUTE ......... ===> YES
8 AUTOCOMMIT ...... ===> YES
run?)
9 BROWSE OUTPUT ... ===> YES
(Y/N - Display SPUFI defaults
(Y/N - Enter SQL statements?)
(Y/N - Execute SQL statements?)
(Y/N - Commit after successful
(Y/N - Browse output data set?)
For remote SQL processing:
10 CONNECT LOCATION ===>
PRESS: ENTER to process
information
END to exit
HELP for more
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 13 of 19
IBM – Java – z/Series Seminars
____ 32. Press the Enter key several times until the sample DDL is displayed. The
DDL will initially appear as shown below. (You will customize the DDL shortly, in step
36.) Notice that a DDL statement can span lines, and that a semicolon is used to
terminate a DDL statement. The DDL below contains just two statements, a DROP
and a CREATE. (Don’t make any changes to the DDL yet.)
DROP PROCEDURE SPTEST01;
CREATE PROCEDURE SPTEST01()
EXTERNAL NAME 'spTest.doIt'
LANGUAGE JAVA
PARAMETER STYLE JAVA
COLLID ZEAM01
PROGRAM TYPE SUB
DYNAMIC RESULT SETS 1
WLM ENVIRONMENT WLMZM01;
Stored Procedure Name
Classname.MethodName
____ 33. Based on the DDL in step 32, what is the name of the Java stored
procedure that will be defined to DB2?
______________________________________________
____ 34. Based on the DDL in step 32, what is the name of the Java class that will
be used then the stored procedure is invoked?
______________________________________________
____ 35. Based on the DDL in step 32, what is the name of the Java method that
will be executed when the stored procedure is invoked?
______________________________________________
____ 36. In this step, your zeam’s stored procedure will be defined to DB2. To
define your zeam’s stored procedure to DB2, make the following changes to the
sample DDL:
a) Comment out the DROP PROCEDURE statement by inserting two
hyphens, --, before the DROP PROCEDURE statement. If it becomes
necessary to execute the CREATE PROCEDURE statement a
second time, you will need to uncomment the DROP PROCEDURE
by removing the two hyphens.
b) The procedure name must match the name used for spTest01 in
the con.prepareCall(ZEAM01.SPTEST01()) in the spInvoke.java
program, as shown in step 24, above.
c) For the COLLID ZEAM01 parameter, this much match the value
for the collection parameter specified in step 18, above.
d) For the WLMZM01 to your zeam’s WLM proc value, such as
WLMZM01, this must match the value specified for your zeam’s WLM
member in step 11, above.
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 14 of 19
IBM – Java – z/Series Seminars
____ 37. While in SPUFI, press PF3, then Press the Enter key several times to
execute the DDL. The CREATE PROCEDURE DDL statement should be processed
without errors. If errors are seen, then correct the DDL and repeat this step until the
DDL runs without errors.
____ 38. Exit from SPUFI and from the DB2 PRIMARY OPTION MENU by
pressing PF3 several times.
____ 39. Before running your stored procedure for the first time, you should know a
few basic WLM commands. WLM commands can be issued from the MVS console
screen. To access the MVS console screen, issue =D.LOG from ISPF. Then display
the status of your zeam’s WLM environment by entering the following command:
/D WLM,APPLENV=WLMZM01
____ 40. Your zeam’s WLM procedure will automatically be started when you
invoke your stored procedure. However, if you make a change to your WLM proc or to
your Java stored procedure after your WLM procedure is started, then you must
refresh your WLM procedure by issuing the following command from the MVS console.
You don’t need to issue this command right now; this is just for reference if you have a
problem when you try to run your stored procedure.
/V WLM,APPLENV=WLMZM01,REFRESH
____ 41. If your stored procedure abends, then you will need to resume your WLM
procedure by issuing the following command from the MVS console. Again, you don’t
need to issue this command right now.
/V WLM,APPLENV=WLMZM01,RESUME
____ 42. After your WLM procedure has been started, it will be allocated
exclusively to WLM. If you need to make changes to your WLM procedure, you will
need to quiesce it so that it can be edited. To quiesce it, issue the following WLM
command from the MVS console. Again, you don’t need to issue this command right
now.
/V WLM,APPLENV=WLMZM01,Q
____ 43. Now you are ready to invoke your stored procedure. The Java program
spInvoke can be used to invoke the stored procedure by issuing the following at an
OMVS command line:
java spInvoke
____ 44. After running the spInvoke program, the data returned from the spTest
program should be displayed. The correct output is a list of DB2 table names.
If no output appears within about 5 seconds, then the spInvoke program is hung. The
typical causes of a hang are an error in your WLM environment setup or a reference to
the wrong WLM environment name in your DDL. You will need to exit from the OMVS
shell by pressing PF2, then entering quit. Check and correct your DDL (in SPUFI) and
your WLM proc (from the ISPF editor), then resume and refresh your WLM procedure
by using the commands described in steps 39, 40, 41, and 42, above (as needed).
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 15 of 19
IBM – Java – z/Series Seminars
To check for errors in the WLMZM01 job, go to SDSF (option =D) and look at your
WLMZM01 job. If there are any errors, edit the WLMZM01 JCL and correct the errors,
then REFRESH and RESUME your job as explained in steps 40 and 41.
Additional problem isolation tips can be found in section 13.3 of the Redbook.
____ 45.
You have completed phase 2 of the lab.
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 16 of 19
IBM – Java – z/Series Seminars
Phase 3 – Installation and use of a Java User Defined Function
____ 46. A Java User Defined Function (UDF) is, in many ways, similar to a Stored
Procedure. Since you have some experience in implementing stored procedures, we
will focus on the differences between setting up stored procedures and user defined
functions, and we will assume that you know the basic mechanics of using SPUFI,
compiling Java programs, and so forth.
____ 47. A Java user defined function is created by extending a special class
called the UDF class. In other words, a Java UDF is always a subclass of the UDF
class.
Let’s take a look at a very simple Java UDF.
import java.sql.*;
import java.lang.*;
import COM.ibm.db2.app.*;
class myUDF extends UDF {
public static int testUDF(int edlev) {
try
{
if (edlev < 14)
return(1);
if (edlev < 18)
return(2);
return(3);
}
catch (Exception e)
{
return(0);
}
}
}
____ 48.
// End of Sample UDF
A Java UDF is always a subclass of which class?
________________________________________________
____ 49.
What is the class name of the sample UDF?
________________________________________________
____ 50.
What is the method name in the sample UDF?
________________________________________________
____ 51. How many input parameters does this UDF accept, and what is (are) the
data type of the parameter(s)?
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 17 of 19
IBM – Java – z/Series Seminars
_____________________________________________________
____ 52. What is the data type that this UDF returns, and what are the possible
values that it might return?
_____________________________________________________
____ 53.
Does the sample UDF access any particular table? If so, which table?
_____________________________________________________
____ 54. The source for the sample UDF can be found in
/u/zeam01/db2sp/classes/myUDF.java.
____ 55.
Compile the myUDF.java file using the javac command.
____ 56. To install a UDF into DB2, you must execute DDL statements, just as you
did to install a stored procedure into DB2. However, the DDL for installing a UDF is
slightly different from the DDL for installing a stored procedure.
Let’s take a look at the DDL that will be used to install the sample Java program
named myUDF.java into DB2. Our UDF will be named FUNCTEST. The DDL below
tells DB2 that a call to FUNCTEST should invoke testUDF, which is a method in Java
class myUDF.
CREATE FUNCTION FUNCTEST(value1 INT)
EXTERNAL NAME ‘myUDF.testUDF’
 classname.methodname
RETURNS INTEGER
 Type of data returned
FENCED
VARIANT
NO SQL
LANGUAGE JAVA
PARAMETER STYLE JAVA
COLLID ZEAM01
WLM ENVIRONMENT WLMZM01;
____ 57. In the DDL in step 56, in what parameter are the class name and method
name of the UDF specified?
_______________________________________________________
____ 58.
Based on the DDL in step 56, what data type does the UDF return?
_______________________________________________________
____ 59. Using SPUFI, enter DDL similar to example in step 56, changing the
COLLID parameter to your zeam’s Collection ID and changing the WLM
ENVIRONMENT parameter to your zeam’s WLM proc value, such as WLMZM01.
(The WLM ENVIRONMENT parameter value must match the value specified for your
zeam’s WLM member in step 11, above.) Execute the DDL to install the UDF into
DB2.
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 18 of 19
IBM – Java – z/Series Seminars
____ 60. Refresh your WLM procedure (see step 40, above) to make the
FUNCTEST UDF available to DB2.
____ 61. An easy way to test the UDF is by invoking it from a simple SQL program.
DB2 comes with a few sample tables. One of those tables, called EMP, contains a
column that contains the EDLEVEL (education level) of each employee. In this step,
you will run a super simple, one-line SQL program (shown below) to perform a query
against the EMP table and generate a short report.
Enter and run the following SQL statement from within SPUFI to test your UDF.
(Create a new PDS member and add the following statement to it by specifying a new
member name to SPUFI.)
SELECT * FROM DSN8910.EMP WHERE FUNCTEST(EDLEVEL)=3;
____ 62. Run the query in step 61 with various comparison values for
FUNCTEST(EDLEVEL), such as 1, 2, or 3.
____ 63. If time permits, and if you have SQL and Java skills, modify the
myUDF.java program to perform other operations against input data. Use the modified
UDF in other queries against the EMP table.
____ 64.
You have completed this lab exercise.
Lab: Implementing Java Stored Procedures and Java User Defined Functions
Page 19 of 19
IBM Wildfire Series
z/OS Java Exploiters and Java Batch
Unit 9: Java on z/OS – Profiling and Problem Isolation
WSC Wildfire Class
© 2012 IBM Corporation
IBM Wildfire Series
Special Considerations for Java on z/OS
 Performance – Best Practices
 Problem Isolation Tools
2
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Java Performance and Reliability Tips
 Use the most current release of Java for z/OS
– http://www.ibm.com/servers/eserver/zseries/software/java
 Redbooks:
– Java Stand-alone Applications on z/OS, Volume I, SG24-7177-00
– Java Stand-alone Applications on z/OS, Volume II, SG24-7291-00
 IBM Java Diagnostics Guides for each level of Java
– Java V5
• SC34-6650 (Use Google to locate)
– Java V6
• http://download.boulder.ibm.com/ibmdl/pub/software/dw/jdk/diagnosis/diag60.pdf
 Start by using the standard best Java coding practices
– The only book you need for performance
• Java Performance Tuning (O’Reilly), by Jack Shirazi
– Other books on performance
• Java Platform Performance: Strategies and Tactics, by Steve Wilson and Jeff Kesselman
• Java Performance and Scalability: Server-Side Programming Techniques, by Dov Bulka
 Stress test and performance test using an industrial strength tool
– IBM product is Rational Performance Tester
– Testing on a development workstation before being deployed into production on a z/OS system is NOT
sufficient
– Investigate and resolve every failure during test, especially transient failures
– Performance / Stress testing tools are expensive, but they are a lot less expensive than a production-time
failure
3
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Java Performance Tips for z/OS
 Avoid excessive quantity and duration of garage collection cycles
 Specify –verbose:gc option to get a garbage collection report
• -verbosegc output goes to stderr
• Okay to use –verbosegc during production (but turn off after GC information has been
gathered)
• Analyze the garbage collection report using IBM Support Assistant
 Consider increasing minimum and maximum heap storage (-Xms and -Xmx
options) if there is excessive GC
• “Excessive” is a relative term, but typical time between GC events should be about once
every 5 to 50 seconds. GC every second is definitely excessive.
• Guideline: Time between GC should be at least 20 times as long as an average GC cycle,
so if GC cycle takes 250 ms, then GC should happen no more than once every 5
seconds.
• Typical goal: Adjust –Xms and -Xmx until GC occurs about once every 10 seconds
– A balancing act
> Smaller heap = more frequent garbage collection -> and more GC overhead
> Larger heap = longer garbage collection event
– Lots more GC options in IBM Java Diagnostics Guides
• Java V5
– SC34-6650
• Java V6
– http://download.boulder.ibm.com/ibmdl/pub/software/dw/jdk/diagnosis/diag60.pdf
4
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Problem Isolation in Java Programs
 RAD V6, V7 Remote Debugger
• Agent Controller runs on z/OS platform to allow program to be
controlled from workstation
• Breakpoints can be set
• Values of variables can be viewed
• Code can be “stepped” line by line
 IBM Support Assistant
•
•
•
•
•
Free downloadable tool
Garbage Collection analysis
Dump analysis
Lots and lots of other features
Techdocs:
– WP101575 Introducing the IBM Support Assistant for WebSphere on z/OS
– WP101612 Getting started with analysis of GC, Heapdumps and Javacores
for WebSphere on z/OS
5
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
z/OS Java Exploiters and Java Batch
Lab 9: Java on z/OS and GC Analysis
WSC Wildfire Class
© 2012 IBM Corporation
IBM Wildfire Series
Lab: Java on z/OS Profiling and Problem Isolation
 IBM Support Assistant
– garbage collection analysis
– memory leak analysis
7
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM Wildfire Series
Trademarks
The following are trademarks of the International Business Machines Corporation in the United States and/or other countries. For a complete list of IBM Trademarks, see www.ibm.com/legal/copytrade.shtml: AIX, AIX 5L, BladeCenter,Blue Gene, DB2,
e-business logo, eServer, IBM, IBM Logo, Infoprint, IntelliStation, iSeries, pSeries, OpenPower, POWER5, POWER5+, Power Architecture, TotalStorage, WebSphere, xSeries, z/OS, zSeries
The following are trademarks or registered trademarks of other companies:
Java and all Java based trademarks and logos are trademarks of Sun Microsystems, Inc., in the United States and other countries or both
Microsoft, Windows, Windows NT and the Windows logo are registered trademarks of Microsoft Corporation in the United States, other countries, or both.
Intel, Intel logo, Intel Inside, Intel Inside logo, Intel Centrino, Intel Centrino logo, Celeron, Intel Xeon, Intel SpeedStep, Itanium, and Pentium are trademarks or registered trademarks
of Intel Corporation or its subsidiaries in the United States and other countries.
UNIX is a registered trademark of The Open Group in the United States and other countries or both.
Linux is a trademark of Linus Torvalds in the United States, other countries, or both.
Other company, product, or service names may be trademarks or service marks of others.
NOTES:
Any performance data contained in this document was determined in a controlled environment. Actual results may vary significantly and are dependent on many factors including system hardware configuration and software design and configuration.
Some measurements quoted in this document may have been made on development-level systems. There is no guarantee these measurements will be the same on generally-available systems. Users of this document should verify the applicable
data for their specific environment.
IBM hardware products are manufactured from new parts, or new and serviceable used parts. Regardless, our warranty terms apply.
Information is provided "AS IS" without warranty of any kind.
All customer examples cited or described in this presentation are presented as illustrations of the manner in which some customers have used IBM products and the results they may have achieved. Actual environmental costs and performance
characteristics will vary depending on individual customer configurations and conditions.
This publication was produced in the United States. IBM may not offer the products, services or features discussed in this document in other countries, and the information may be subject to change without notice. Consult your local IBM business
contact for information on the product or services available in your area.
All statements regarding IBM's future direction and intent are subject to change or withdrawal without notice, and represent goals and objectives only.
Information about non-IBM products is obtained from the manufacturers of those products or their published announcements. IBM has not tested those products and cannot confirm the performance, compatibility, or any other claims related to non-IBM
products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products.
Prices are suggested US list prices and are subject to change without notice. Starting price may not include a hard drive, operating system or other features. Contact your IBM representative or Business Partner for the most current pricing in your
geography.
Any proposed use of claims in this presentation outside of the United States must be reviewed by local IBM country counsel prior to such use.
The information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new editions of the publication. IBM may make improvements and/or
changes in the product(s) and/or the program(s) described in this publication at any time without notice.
Any references in this information to non-IBM Web sites are provided for convenience only and do not in any manner serve as an endorsement of those Web sites. The
materials at those Web sites are not part of the materials for this IBM product and use of those Web sites is at your own risk.
IBM makes no representation or warranty regarding third-party products or services including those designated as ServerProven, ClusterProven or BladeCenter Interoperability Program products. Support for these third-party (non-IBM) products is
provided by non-IBM Manufacturers.
IBM may have patents or pending patent applications covering subject matter in this document. The furnishing of this document does not give you any license to these patents. Send license inquires, in writing, to IBM Director of Licensing, IBM
Corporation, New Castle Drive, Armonk, NY 10504-1785 USA.
8
© 2012 IBM Corporation
© 2003 IBM Corporation
IBM – Java – z/Series Seminars
Lab 9: Analyzing Java Garbage Collection data using the
IBM Support Assistant
Version of November 29, 2012
© Copyright 2012 International Business Machines Corporation
IBM – Java – z/Series Wildfire Seminars
Lab: Analyzing Java Garbage Collection data using the
IBM Support Assistant
Approximate time for completion:
The anticipated typical time for completion is 15 to 30 minutes, but varies depending
upon the student’s level of familiarity with Unix System Services and Java.
The objective of this lab is to provide a very brief introduction to using the IBM Support
Assistant to analyze Java trace data and heap dump data.
The IBM Support Assistant (ISA) is a complimentary software support solution that helps
you find answers and resolve issues with IBM software products..
In this lab, you will use a tool that is part of the IBM Support Assistant to analyze a Java
garbage collection trace.
Lab Prerequisites
IBM z/Series system
Java V6.0.1
Access to TSO and Unix Systems Services.
Windows workstation with IBM Support Assistant installed
When logging on to TSO, specify IKJACCNT in the Procedure field.
Lab: Using the IBM Support Assistant
Page 2 of 6
IBM – Java – z/Series Wildfire Seminars
Lab Steps
____ 1.
The IBM Support Assistant (ISA) is a no-charge, Eclipse-based tool from
IBM. Briefly review the material on the following web site to get a general
overview of the ISA. Do not install the ISA on your workstation, as it is
already installed.
http://www.ibm.com/software/support/isa/
____ 2.
The ISA consists of a base product and a set of add-on tools. In this lab,
you will use some of the add-on tools. The ISA on the lab systems
already includes the add-on tools, so please do not reinstall the add-on
tools. However, you should become familiar with the add-on tools by
briefly reviewing the following web site:
http://www.ibm.com/support/docview.wss?rs=3455&uid=swg27013116
____ 3.
In this lab, you will profile the Looper.java program, which is a standalone
Java program.
The Looper.java program is shown on the next page.
Lab: Using the IBM Support Assistant
Page 3 of 6
IBM – Java – z/Series Wildfire Seminars
import java.io.*;
import java.util.*;
import java.text.*;
class Looper {
public static void main(String[] argv) {
int i,j;
int numinterations = 100;
System.out.println ("\nLooper has started and is now waiting for you to");
System.out.println ("press the Enter key to tell Looper to continue running.\n");
try{
System.in.read();
}
catch (IOException e)
{
System.err.println(e);
}
System.out.println ("Running for " + numinterations + " interations\n");
for (j=1; j<numinterations; j++)
{
// the next four statements are for support of the GC lab
String gctestdata1 = new String("this is a long string for support of the GC lab");
String gctestdata2 = gctestdata1 + gctestdata1 + gctestdata1;
String gctestdata3 = gctestdata2 + gctestdata2 + gctestdata2;
String gctestdata4 = gctestdata3 + gctestdata3 + gctestdata3;
String gctestdata5 = gctestdata4 + gctestdata4 + gctestdata4;
String gctestdata6 = gctestdata5 + gctestdata5 + gctestdata5;
String gctestdata7 = gctestdata6 + gctestdata6 + gctestdata6;
String gctestdata8 = gctestdata7 + gctestdata7 + gctestdata7;
String gctestdata9 = gctestdata8 + gctestdata8 + gctestdata8;
String gctestdata10 = gctestdata9 + gctestdata9 + gctestdata9;
System.out.print("Interation "+ j + " ");
System.out.println(DateFormat.getDateTimeInstance
(DateFormat.LONG,DateFormat.LONG,
Locale.US).format(new Date()));
try {
Thread.sleep(100);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}/* end for */
System.out.println("\nLooper Finished");
} /* end main */
}
____ 4.
Although any release of Java can generate a GC log, we will use Java V6
in this lab. Edit your .profile file and change the comment character (#) on
Lab: Using the IBM Support Assistant
Page 4 of 6
IBM – Java – z/Series Wildfire Seminars
the JAVA_HOME statements so that the V6.0.1 JVM is used. (You may
have made this change already in a previous lab.) For example:
export JAVA_HOME=/shared/java/J6.0.1
____ 5.
Exit from OMVS and then reenter OMVS so that the change that you
made in step 4 (above) will take effect.
____ 6.
Verify that your environment is set to use Java V6 by issuing the following
command at the OMVS shell prompt:
java –version
____ 7.
Compile the Looper.java program. For example:
javac Looper.java
____ 8.
Execute the Looper.java program, using a 32 MB maximum heap size and
specify the –vergosegc option. Redirect the GC log, which is normally
sent to stderr, to a file. For example:
java -verbosegc -mx32m Looper 2>gctestdata
____ 9.
When prompted, press the Enter key to allow Looper to continue running.
Looper will run for 100 iterations. When it finishes, verify that GC data
was collected by browsing the gctestdata file.
____ 10. Next, you will use FTP to download the gctestdata file to your workstation.
To use FTP, you will first need to get to a windows command prompt. On
your workstation, access a windows command prompt clicking on Start –
Run, then entering cmd. A windows command prompt box will be
opened.
____ 11. A directory named \temp should already exist on your workstation. Set
\temp as your current directory by entering:
cd \temp
____ 12. If \temp does not exist, then you can create it by entering:
mkdir \temp
Then enter cd \temp to set /temp as your current directory
____ 13. FTP to the mig system and GET the gctestdata file to your workstation.
Use the default transfer mode, which is ASCII. For example:
ftp mig.null.washington.ibm.com
User:<zeamtt>
Password:< (enter the password) >
Lab: Using the IBM Support Assistant
Page 5 of 6
IBM – Java – z/Series Wildfire Seminars
ftp> cd /u/zeam01/classes
ftp> get gctestdata
ftp> quit
____ 14. Start the IBM Support Assistant by clicking on its icon on your
workstation’s desktop.
____ 15. Select Analyze Problem.
____ 16. Select Tools.
____ 17. Select IBM Monitoring and Diagnostic Tools for JavaTM - Garbage
Collection and Memory Visualizer..
____ 18. Select Launch.
____ 19. Select Browse.
____ 20. Select Remote Artifact Browse and then expand the directory tree to
locate the gctestdata file that you copied to your workstation’s /temp
directory.
____ 21. Select Okay, then Next to load the gctestdata file into PMAT.
____ 22. Explore the various views by clicking on the tabs at the bottom of the
screen for each of the views.
____ 23. You have completed the IBM Support Assistant lab.
Lab: Using the IBM Support Assistant
Page 6 of 6