Deploying the servlet examples

You can use the CICS® bundle project that is supplied with each servlet example to deploy the application to a Liberty JVM server that is running in CICS.

Before you begin

You must create an example web application, as described in Getting started with the servlet examples. You must also have permission to create and install CICS resources in the region. You should also install the Websphere Developer Tooling OSGi Application Development feature, see Setting up the development environment.
To deploy the CICS Java™ Database Connectivity (JDBC) example, you must complete an additional prerequisite step:
  1. Create and install a DB2CONN CICS resource definition and ensure that its status is connected. The DB2 plan that is specified in the CICS DB2CONN definition should be bound with a package list specified as follows:
    PKLIST(NULLID.*)

About this task

CICS loads and runs Java applications from zFS, so you must deploy your compiled applications to a directory in zFS that the CICS region can access. For the DB2® example, you must also have a sample DB2 database available.

The preferred method to deploy and install the applications is to use a CICS bundle project. By using this method you can then use CICS facilities to manage those bundle project application resources. A CICS bundle project packages a set of plug-in projects, dynamic web projects, and CICS resources that are logically deployed and managed as a single unit. You can use this method for simple web applications, such as the Hello World example, and more complex web applications, such as the other servlet examples.

An alternative method to deploy and install the applications is to use the Liberty deployment mechanism to deploy WAR or EBA files. You can export the project as a WAR or EBA file and use FTP to copy the file to the dropins directory of a Liberty JVM server. You can use this method for simple web applications, such as the Hello World example.

Procedure

  • To deploy an example by using a CICS bundle project, you can use the CICS Explorer SDK.
    1. Right-click the bundle project and click Export Bundle Project to z/OS UNIX File System.
    2. Follow the wizard to deploy the bundle to a location in zFS that can be accessed by the CICS region.
      To use the sample BUNDLE resource definitions in the sample group DFH$WLP use /tmp/cicsts52 as the parent directory on zFS.
      The CICS Explorer SDK deploys the CICS bundle and the associated projects to zFS. If the CICS bundle includes .osgibundle or .warbundle artifacts, the associated projects are built as specified by their project build properties and are also exported.
    3. For the CICS Java Database Connectivity (JDBC) example, there is a bundle project to deploy. Complete steps 1 and 2 for this bundle project.
    4. Edit the sample DFHWLP.jvmprofile to turn on the automatic configuration option with the -Dcom.ibm.cics.jvmserver.wlp.autoconfigure=true system property. The server.xml is automatically generated and can be found in the WLP_USER_DIR/servers/server_name directory. You can use the z/OS® UNIX Files view to browse the directory structure to edit the file. You should specify values for -Dcom.ibm.cics.jvmserver.wlp.server.host, and -Dcom.ibm.cics.jvmserver.wlp.server.http.port or -Dcom.ibm.cics.jvmserver.wlp.server.https.port according to your own environment. For the JDBC example, set the -Dcom.ibm.cics.jvmserver.wlp.jdbc.driver.location property to the DB2 JDBC driver location.
    5. In the CICSplex Explorer view, select the CICS region where you want to run the servlet examples.
    6. Start of changeInstall the JVMSERVER resource, DFHWLP, which is in the sample group DFH$WLP.End of change
      The sample resource creates a Liberty JVM server in the CICS region.

      The Liberty JVM server creates a directory structure in zFS, including a server.xml file and a dropins directory for web applications. You can check the status of the JVM server by clicking Operations > Java > JVM Servers.

    7. Open the Bundle Definitions view by clicking Definitions > Bundle Definitions.
      This view lists all the bundle definitions for the CICS region.
    8. Install the sample bundle resource definitions in the sample group DFH$WLP.
      The sample bundle resources definition WLPHELLO is required for the CICS Hello World example. WLPTSQ is required for the CICS Temporary Storage Queue (TSQ) example. WLPJDBC is required for the JDBC example. The sample definitions specify /tmp/cicsts52 as the location where the CICS bundles are deployed.
    9. If you have configured the cicsts:security-1.0 feature, or are using autoconfigure, ensure you have also configured the required security rules. See Configuring security for a Liberty JVM server.
    10. Optional: You might want to change a supplied sample. If you previously deployed the same sample and are now redeploying it, you must disable and re-enable the bundle for the new version of the sample to run.
    The WAR or EBA file (depending on the example) is loaded in the Liberty profile server and all OSGi bundles are registered in the OSGi framework.
  • To deploy a simple example that follows the Liberty deployment model, you must configure and enable a JVM server in CICS.
    Enabling the JVM server creates the dropins directory.
    1. Edit the DFHWLP.jvmprofile to turn on automatic configuration with the -Dcom.ibm.cics.jvmserver.wlp.autoconfigure=true system property.
    2. In the CICSplex Explorer view, select the CICS region where you want to run the servlet example.
    3. Start of changeInstall the JVMSERVER resource, DFHWLP, which is in the sample group DFH$WLP.End of change
      The sample resource creates a Liberty JVM server in the CICS region.

      The Liberty JVM server creates a directory structure in zFS, including a server.xml file and a dropins directory for web applications. You can check the status of the JVM server by clicking Operations > Java > JVM Servers.

    4. In the Resource perspective, right-click the dynamic web project and export it to your local workstation as a WAR or EBA file.
    5. Use FTP to copy the WAR or EBA file to the dropins directory in binary mode.
    6. You can edit the server.xml file to change the host name and the port number.

Results

You deployed a web application that contains servlets and a JSP page to a Liberty JVM server that is running in CICS and configured the Liberty JVM server to use a host name and port number.

What to do next

You can access the web application from a web browser to check the configuration of the Liberty JVM server, as described in Running the servlet examples.