CICS-Run Java application-(1) Run a simple sample app

Introduction

COBOL, PL / I, and Asembler are often used as application development languages for CICS Transaction Server for z / OS, but Java has also been supported for a long time. This means that you can write CICS applications in Java. A Java Class Library (JCICS) equivalent to the EXEC CICS commands is provided, so you can use Java methods to perform operations such as EXEC CICS LINK or EXEC CICS START. Here, we will try to actually run the CICS-Java application sample (OSGi compliant).

Related article

CICS-Run Java application-(1) Run simple sample application CICS-Run Java application-(2) Build management by Maven CICS-Run Java application-(3) Build management with Gradle CICS-Run Java application-(4) Spring Boot application

Environmental information

Development environment Windows10 CICS Explorer V5.6(Beta)

** Execution environment ** z/OS V2.4 CICS Transaction Server for z/OS V5.6(Beta)

About CICS Java support

Here's a summary of CICS's Java support. CICS supports OSGi-compliant Java applications. To run a CICS application implemented in Java, the following procedure is required.

** Runtime preparation ** In order to execute a Java application, create a resource definition called JVMSERVER in the target CICS region and prepare a Java execution environment.

development of Development work is done with the free Eclipse-based tool "CICS Explorer". Create a Java app that imports the JCICS library and package it in the form of an OSGi bundle (like an extension of a jar). (Reference: OSGI Overview) At this time, the first logic to be recognized as a CICS program needs to be implemented in the main function. Package some OSGi Bundles in units called "CICS bundles".

** Deploy ** Transfer the CICS bundle onto USS on z / OS in the execution environment. Create a BUNDLE definition in the resource definition of the CICS region to recognize the CICS bundle (Java app) transferred on the USS. Create a PROGRAM definition in the resource definition of the CICS region and register the Java class contained in BUNDLE as a CICS program.

The relationship between each CICS resource definition and the entity is as follows. image.png

Advance preparation

Development environment

Download and set up an Eclipse-based tool called CICS Explorer, referring to the following areas. Reference: Downloading and starting CICS Explorer

As a host connection definition, configure an FTP connection for the z / OS on which the target CICS runs. image.png

Execution environment

Prepare a CICS region to run the sample. For now, we'll use a region named ** CT56B4A1 **. Add a resource called JVMServer to run Java applications.

JVM profile

Prepare the JVM profile on USS. (Properties for the JVMServer are effectively specified in a file on this USS. The JVMSERVER resource definition points to the filename of this JVM profile.) A sample is provided, so copy it and use it.

Create a directory called /var/cicsts/cicsts56/CT56B4A1/JVMProfiles and copy /usr/lpp/cicsts/cicsts56/JVMProfiles/DFHOSGI.jvmprofile (sample definition for OSGi located under the CICS installation directory) to it. To do. Customize as appropriate for your environment.

DFHOSGI.jvmprofile excerpt


JAVA_HOME=/usr/lpp/java/J8.0_64/
WORK_DIR=/var/cicsts/cicsts56/CT56B4A1/work
-Xms32M
-Xmx256M
-Xmso1M
-Xgcpolicy:gencon
-Xscmx256M
-Xshareclasses:name=cicsts%g,groupAccess,nonfatal
-Xtune:virtualized
-Dcom.ibm.tools.attach.enable=no
_BPXK_DISABLE_SHLIB=YES

SIT

Specify the directory where the above properties file is located in the SIT parameter "JVMPROFILEDIR".

JVMPROFILEDIR=/var/cicsts/cicsts56/CT56B4A1/JVMProfiles 

Restart the region for the changes to take effect.

JVM Server definition

Prepare the JVMSERVER resource definition. Copy the JVMSERVER definition "DFHJVMS" in the product-provided group called DFH $ OSGI to an appropriate group and install it.

OBJECT CHARACTERISTICS                                    CICS RELEASE = 0730 
 CEDA  View JVmserver( DFHJVMS  )                                             
  JVmserver      : DFHJVMS                                                    
  Group          : TAG$OSGI                                                   
  DEScription    : CICS JVM server to run OSGi samples                        
  Status         : Enabled            Enabled | Disabled                      
  Jvmprofile     : DFHOSGI                                        (Mixed Case)
  Lerunopts      : DFHAXRO                                                    
  Threadlimit    : 015                1-256                                   
 DEFINITION SIGNATURE                                                         
  DEFinetime     : 06/02/20 17:28:17                                          
  CHANGETime     : 06/02/20 17:28:17                                          
  CHANGEUsrid    : CICSUSER                                                   
  CHANGEAGEnt    : CSDApi             CSDApi | CSDBatch                       
  CHANGEAGRel    : 0730                                                       

It is OK if it is enabled by looking at CEMT I JVMSERVER.

I JVMS                                               
STATUS:  RESULTS - OVERTYPE TO MODIFY                
 Jvm(DFHJVMS ) Ena     Prf(DFHOSGI ) Ler(DFHAXRO )   
    Threadc(000) Threadl( 015 ) Cur(9965280)         

bundle File placement directory

Create a directory on USS to place the bundle file. Here, we will create a directory called / var / cicsts / cicsts56 / CT56B4A1 / bundles /.

Sample application operation check

Reference: Java samples: JCICS examples

Creating a sample project

Select Window-Settings from the CICS Explorer menu to open the settings window. Plugin Development-Select your target platform and click Add. image.png

Select the target CICS version in the template. Here, select CICS TS V5.6. image.png

Check and apply the added CICS TS 5.6. image.png

In the Java perspective, select File-New-Other from the menu image.png

Select CICS Bundle OSGi Sample image.png

Continue as it is image.png

End as it is image.png

A sample project is created. image.png

Check the contents of the sample

There are several sample apps provided for this project, but let's take a look at the simplest Hello World source. (examples.hello.HelloCICSWorld.java included in the com.ibm.cics.server.examples.hello project (OSGi bundle))

HelloCICSWorld.java


package examples.hello;

import com.ibm.cics.server.CommAreaHolder;
import com.ibm.cics.server.Task;

public class HelloCICSWorld
{
    public static void main(CommAreaHolder CAH)
    {
        Task t = Task.getTask();
        if ( t == null )
            System.err.println("HelloCICSWorld example: Can't get Task");
        else
            t.out.println("Hello from a Java CICS application");
    }
}

JCICS com.ibm.cics.server.Task is used. Task.out means PrintWriter for terminal output, so it is the logic to send a simple character string to the terminal. Reference: [Javadoc --Task](https://www.ibm.com/support/knowledgecenter/SSGMCP_5.6.0/reference-javadocs/jcics-javadoc/com/ibm/cics/server/Task.html?view=embed# out)

Let's check META-INF / MANIFEST.MF of the same project.

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Hello Plug-in
Bundle-SymbolicName: com.ibm.cics.server.examples.hello
Bundle-Version: 1.0.0
Bundle-RequiredExecutionEnvironment: J2SE-1.4,
 J2SE-1.5,
 JavaSE-1.6
Import-Package: com.ibm.cics.server;version="[1.0.0,2.0.0)"
CICS-MainClass: examples.hello.HelloCICSWorld, examples.hello.HelloWorld

The CICS-MainClass specification specifies a class that has a main method. The main method of the class specified here can be recognized as a CICS program (it can be linked with the program definition).

Check out the CICS bundle project called com.ibm.cics.server.examples.bundle. If you open META-INF / cics.xml in the CICS Bundle Manifest Editor, you can see that it contains the OSGi bundle above. image.png

Open com.ibm.cics.server.examples.hello.osgibundle. image.png

Check the value of jvmserver specified here. You must specify the name of the JVMSERVER definition to run here. Modify it according to the name of the JVMSERVER definition created in the preparation. If you copy the sample definition with the same name, it will be DFHJVMS, so you do not need to change it.

Deploy your application to CICS

Deploy to CICS in units of "CICS bundles". Right-click the com.ibm.cics.server.examples.bundle project and click Export Bundle Project to z / OS UNIX File System. image.png

Select Export to a specific location in the file system and Next image.png

Specify the directory for arranging the bundle file created earlier and exit image.png

Check the message image.png The bundle file has been placed on USS.

Copy each resource in the CICS-supplied DFH $ OSGI group to the appropriate group. Customize the BUNDLE definition "DFH $ OSGB" and set the BUNDLEDIR value to the directory where you placed the bundle files above (/var/cicsts/cicsts56/CT56B4A1/bundles/com.ibm.cics.server.examples.bundle_1. Replace with 0.0).

OVERTYPE TO MODIFY                                        CICS RELEASE = 0730
 CEDA  ALter Bundle( DFH$OSGB )                                              
  Bundle         : DFH$OSGB                                                  
  Group          : TAG$OSGI                                                  
  DEScription  ==> CICS bundle containing OSGi sample bundles                
  Status       ==> Enabled            Enabled | Disabled                     
  BUndledir    ==> /var/cicsts/cicsts56/CT56B4A1/bundles/com.ibm.cics.server.
  (Mixed Case) ==> examples.bundle_1.0.0                                     
               ==>                                                           
               ==>                                                           
               ==>                                                           
  BAsescope    ==>                                                           
  (Mixed Case) ==>                                                           
               ==>                                                           
               ==>                                                           
               ==>                                                           
 DEFINITION SIGNATURE                                                        
  DEFinetime     : 06/02/20 18:27:37                                         
  CHANGETime     : 06/02/20 18:27:37                                         

Install it and make sure it is enabled.

I BUNDLE                                                 
STATUS:  RESULTS - OVERTYPE TO MODIFY                    
 Bun(DFH$OSGB) Ena         Par(00003) Tar(00003)         
    Enabledc(00003) Bundlei(com.ibm.cics.server.exampl)  

By the way, if you check the resource definition with CICS Explorer, you can check not only the BUNDLE definition but also the BUNDLE PARTS included in BUNDLE. image.png

Sample execution

This time we will run the Hello World sample, so we will install additional resource definitions related to this sample. Reference: Running the Hello World example

The program definition "DFJ $ JHE2" and the transaction definition "JHE2". The actual Java program has already been installed as BUNDLE. Both are provided in DFH $ OSGI, so copy them and install them as they are. By the way, if you take a look at the definition of DFH $ JHE2,

OBJECT CHARACTERISTICS                                    CICS RELEASE = 0730 
 CEDA  View PROGram( DFJ$JHE2 )                                               
  PROGram        : DFJ$JHE2                                                   
  Group          : TAG$OSGI                                                   
  DEScription    : OSGi Hello CICS world sample program                       
  Language       :                    CObol | Assembler | Le370 | C | Pli     
  RELoad         : No                 No | Yes                                
  RESident       : No                 No | Yes                                
  USAge          : Normal             Normal | Transient                      
  USElpacopy     : No                 No | Yes                                
  Status         : Enabled            Enabled | Disabled                      
  RSl            : 00                 0-24 | Public                           
  CEdf           : Yes                Yes | No                                
  DAtalocation   : Any                Below | Any                             
  EXECKey        : Cics               User | Cics                             
  COncurrency    : Required           Quasirent | Threadsafe | Required       
  Api            : Cicsapi            Cicsapi | Openapi                       
 REMOTE ATTRIBUTES                                                            
  DYnamic        : No                 No | Yes                                
  REMOTESystem   :                                                            
  REMOTEName     :                                                            
  Transid        :                                                            
  EXECUtionset   : Fullapi            Fullapi | Dplsubset                     
 JVM ATTRIBUTES                                                               
  JVM            : Yes                No | Yes                                
  JVMClass       : examples.hello.HelloCICSWorld                              
  (Mixed Case)   :                                                            
                 :                                                            
                 :                                                            
                 :                                                            
  JVMServer      : DFHJVMS                                                    
  JVMProfile     :                                                (Mixed Case)
 JAVA PROGRAM OBJECT ATTRIBUTES                                               
  Hotpool        : No                 No | Yes                                
...

Like this, JVM: Yes, JVMClass: examples.hello.HelloCICSWorld, JVMServer: DFHJVMS are specified (classes installed by BUNDLE PARTS). * If the JVM Server name created in advance is different, please correct it accordingly.

Now that the resources are in place, let's run it. Execute a JHE2 transaction from a CICS terminal. image.png The string output from the Java program Hello from a Java CICS application is displayed! This confirms that Java worked as a CICS program.

Recommended Posts

CICS-Run Java application-(1) Run a simple sample app
A simple sample callback in Java
Create a docker image that runs a simple Java app
[Java] Draw a simple pattern
How to deploy a simple Java Servlet app on Heroku
A Simple CRUD Sample Using Java Servlet / JSP and MySQL
3 Implement a simple interpreter in Java
I made a shopify app @java
Run Java application in Azure Batch
Run a batch file from Java
Access Teradata from a Java application
Run an application made with Java8 with Java6
Create a simple web application with Dropwizard
A simple sample of ArBiMap (two-way map)
Java beginner tried to make a simple web application using Spring Boot
Create a TODO app in Java 7 Create Header
Try making a calculator app in Java
Deploy a Java web app on Heroku
[Azure] I tried to create a Java application for free-Web App creation- [Beginner]
Java Callback Simple Sample Part2 Anonymous Class Example
Create a simple search app with Spring Boot
Create a simple bulletin board with Java + MySQL
Connect to Aurora (MySQL) from a Java application
java I tried to break a simple block
A collection of simple questions for Java beginners
Ssh connect using SSHJ from a Java 6 app
[Java] Generics sample
Java sample code 02
Java sample code 03
Java 9+ application status
Selenium sample (Java)
Java GUI sample
Java sample code 01
How to run the SpringBoot app as a service
[Tutorial] Download Eclipse → Run the application with Java (Pleiades)
[Tutorial] Download Eclipse → Run Web application with Java (Pleiades)
[Personal memo] Make a simple deep copy in Java
Let's make a robot! "A simple demo of Java AWT Robot"
Develop a Java application that uses Amazon SQS (Part 1)
Create a JAVA WEB application and try OMC APM
Develop a Java application that uses Amazon SQS (Part 2)
Java11: Run Java code in a single file as is