Sample RESTful web application for deployment to a Liberty JVM server in CICS. The application is supplied with two REST resources:
Key Features:
InfoResource— queries the JVM server environment using system properties and uses JAXB beans to return a JSON response detailing the CICS environmentReverseResource— uses the JCICS API to link to the COBOL programEDUCHANusing channels and containers; an input string is passed toEDUCHAN, which is reversed and returned along with the time from CICS
Further extensions to this application are available in cics-java-liberty-restappext, which provides additional code examples for accessing CICS resources from Java using the JCICS API.
- Prerequisites
- Downloading
- Check dependencies
- Building the Sample
- Deploying to a CICS Liberty JVM server
- Running the Sample
- License
- CICS TS V5.5 or later with a configured Liberty JVM server
- Java SE 8 or later on the workstation
- One of the following on your workstation:
- Eclipse with the IBM CICS SDK for Java EE, Jakarta EE and Liberty
- An IDE of your choice that supports Gradle or Maven (or can run the wrappers)
- Clone the repository using your IDE's support, such as the Eclipse Git plugin
- or, download the sample as a ZIP and unzip onto the workstation
The following source components are supplied in cics-java-liberty-restapp-app/src/main/java:
Package com.ibm.cicsdev.restapp
CICSApplication— sets theApplicationPathfor resources in this applicationInfoResource— returns JSON structure using theCICSInformationbeanReverseResource— returns JSON structure using theReverseResultbean
Package com.ibm.cicsdev.restapp.bean
CICSEnvironment— JAXB bean returning JSON structure containing CICS product and version informationCICSInformation— JAXB bean returning JSON structure containing CICS applid, time, JVM server name, and an instance ofCICSEnvironmentReverseResult— JAXB bean returning JSON structure containing the input and output containers sent to theEDUCHANCOBOL program
Supporting files:
DFHCSD.txt— DFHCSDUP sample input stream for the CICS BUNDLE resource definitionEDUCHAN.cbl— sample CICS COBOL program that returns the date, time, and reversed input using channels and containers
The sample includes Eclipse project configurations, Gradle and Maven build files, and Gradle/Maven wrappers — offering a wide range of build options with any tooling or IDE.
Run the Gradle build from the top-level cics-java-liberty-restapp directory. A WAR file is created in cics-java-liberty-restapp-app/build/libs and a CICS bundle ZIP in cics-java-liberty-restapp-cicsbundle/build/distributions.
The target JVM server is controlled by the cics.jvmserver property (default DFHWLP):
Gradle wrapper (Linux/Mac):
./gradlew clean buildGradle wrapper (Windows):
gradlew.bat clean buildSetting the JVM server name:
./gradlew clean build "-Pcics.jvmserver=MYJVM"Run the Maven build from the top-level cics-java-liberty-restapp directory. A WAR file is created in cics-java-liberty-restapp-app/target and a CICS bundle ZIP in cics-java-liberty-restapp-cicsbundle/target.
Maven wrapper (Linux/Mac):
./mvnw clean verifyMaven wrapper (Windows):
mvnw.cmd clean verifySetting the JVM server name:
./mvnw clean verify "-Dcics.jvmserver=MYJVM"To import the sample into Eclipse:
- Clone the repository using your IDE's support, such as the Eclipse Git plugin, or download the ZIP archive and unzip it
- File → Import → General → Existing Projects into Workspace → select the repository root directory → Finish
- This imports the root project only; subprojects are discovered in the next step
- Right-click
cics-java-liberty-restapp→ Gradle → Refresh Gradle Project (or Maven → Update Project) to import-appand-cicsbundle - To import the Eclipse CICS bundle project, right-click the
cics-java-liberty-restapp-cicsbundle-eclipsefolder in Project Explorer → Import as Project- This project is excluded from the Gradle/Maven build so it is never auto-discovered
The project is pre-configured with the CICS TS V5.5 with Java EE and Liberty 8 library in the Eclipse classpath. The project should compile immediately after import if you have the CICS Explorer SDK installed.
If you see compilation errors, or want to use Gradle or Maven for dependency management, use one of the options below.
For Gradle (Buildship):
- Right-click
cics-java-liberty-restapp→ Run As → Gradle Build... - Enter
clean buildin the Gradle Tasks field and click Run - Once the build succeeds, right-click
cics-java-liberty-restapp→ Gradle → Refresh Gradle Project - Clean and rebuild: Project → Clean → select all → Clean
For Maven (m2e):
- Right-click
cics-java-liberty-restapp→ Maven → Update Project → check Force Update of Snapshots/Releases - Clean and rebuild: Project → Clean → select all → Clean
The application must be built into a WAR file and deployed to Liberty using a CICS bundle. You will need a Liberty JVM server configured in your CICS region.
Required Liberty features — this sample uses the javax.* namespace (Java EE 8). Add the following to your server.xml:
<featureManager>
<feature>jaxrs-2.1</feature>
<feature>servlet-4.0</feature>
</featureManager>Note: Do not use Jakarta EE 10 features (
restfulWS-3.1,servlet-6.0) with this sample — those features use thejakarta.*namespace and are incompatible with thejavax.*API used here. Liberty will fail to dispatch requests and returnSRVE0190E: File not found.
A sample server.xml is provided in etc/config/server.xml.
Download and compile the supplied COBOL program EDUCHAN and deploy it into CICS to support the reverse function.
- Build the project using Gradle or Maven as described above — the CICS bundle ZIP is produced automatically
- Upload the CICS bundle ZIP in binary to zFS (from
cics-java-liberty-restapp-cicsbundle/build/distributionsfor Gradle, orcics-java-liberty-restapp-cicsbundle/targetfor Maven) - Connect to USS (e.g. via SSH) and extract the ZIP:
jar -xvf cics-java-liberty-restapp-cicsbundle-1.0.0.zip
- In CICS, create a BUNDLE resource definition pointing to the extracted directory and install it
A sample DFHCSDUP input file is provided in etc/DFHCSD.txt.
- Import the
cics-java-liberty-restapp-cicsbundle-eclipseproject into Eclipse: right-click the folder in Project Explorer → Import as Project - Build the application WAR in Eclipse using Gradle or Maven (see Option 2 above)
- Right-click
cics-java-liberty-restapp-cicsbundle-eclipse→ Export Bundle Project to z/OS UNIX File System - The bundle is exported to the
cics-java-liberty-restapp-bundle_1.0.0directory on zFS - In CICS, create and install a BUNDLE resource definition pointing to that zFS directory
- Build the WAR using Gradle or Maven
- Upload the WAR file to zFS
- Add a
<webApplication>element to your Libertyserver.xmlpointing to the WAR location - Restart or update the JVM server
Once deployed, use the context root cics-java-liberty-restapp. Issue the following HTTP GET requests:
Get CICS environment information:
http://host:port/cics-java-liberty-restapp/rest/cicsinfo
Example response:
{"applid":"IYK2Z32E","jvmServer":"DFHWLP","time":"2016-09-09T16:19:55.384Z","cicsEnvironment":{"cicsProduct":"CICS Transaction Server for z/OS","cicsVersion":"5.3.0"}}Reverse the default string "Hello from Java":
http://host:port/cics-java-liberty-restapp/rest/reverse
Example response:
{"time":"2016-09-09T16:15:52.756Z","original":"Hello from Java","reverse":"avaJ morf olleH","truncated":false}Reverse a custom string:
http://host:port/cics-java-liberty-restapp/rest/reverse/ilovecics
Example response:
{"time":"2016-09-09T16:15:32.466Z","original":"ilovecics","reverse":"scicevoli","truncated":false}This project is licensed under the Eclipse Public License Version 2.0.
- cics-java-liberty-restappext — extended code examples for accessing CICS resources from Java
- IBM CICS documentation
We welcome contributions. Please raise issues and pull requests in the GitHub repository.