Installing OSGi bundles in a JVM server

To deploy a Java application in a JVM server, you must install the OSGi bundles for the application in the OSGi framework of the target JVM server.

Before you begin

A CICS® bundle that contains the OSGi bundles for the application must be deployed to zFS. The target JVM server must be running in the CICS region.

About this task

A CICS bundle can contain one or more OSGi bundles and services. Because the CICS bundle is the unit of deployment, all the OSGi bundles and services are managed together as part of the BUNDLE resource. The OSGi framework also manages the life cycle of the OSGi bundles and services, including the management of dependencies and versioning.

As a best practice, ensure that all OSGi bundles that comprise a Java application are deployed in the same CICS bundle. Using this method, you can manage the application as a single entity by using the BUNDLE resource. If there are dependencies between OSGi bundles, deploy them in the same CICS bundle. When you install the CICS BUNDLE resource, CICS ensures that all the dependencies between the OSGi bundles are resolved.

If you have dependencies on an OSGi bundle that contains a library of common code, the best practice is to create a separate CICS bundle for the library. In this case, it is important to install the CICS BUNDLE resource containing the library first. If you install the Java application before the CICS bundles that it depends on, the OSGi framework is unable to resolve the dependencies of the Java application.

Procedure

  1. Create a BUNDLE resource that specifies the directory of the bundle in zFS:
    1. Click Definitions > Bundle Definitions in the CICS Explorer® menu bar to open the Bundles Definitions view.
    2. Right-click anywhere in the view and click New to open the New Bundle Definition wizard. Enter the details for the BUNDLE resource in the wizard fields.
    3. Install the BUNDLE resource. You can either install the resource in an enabled or disabled state:
      • If you install the resource in a DISABLED state, CICS installs the OSGi bundles in the framework and resolves the dependencies, but does not attempt to start the bundles.
      • If you install the resource in an ENABLED state, CICS installs the OSGi bundles, resolves the dependencies, and starts the OSGi bundles. If the OSGi bundle contains a lazy bundle activator, the OSGi framework does not attempt to start the bundle until it is first called by another OSGi bundle.
  2. Optional: Enable the BUNDLE resource to start the OSGi bundles in the framework if the resource is not already in an ENABLED state.
  3. Click Operations > Bundles in the CICS Explorer menu bar to open the Bundles view. Check the state of the BUNDLE resource.
    • If the BUNDLE resource is in an ENABLED state, CICS was able to install all the resources in the bundle successfully.
    • If the BUNDLE resource is in a DISABLED state, CICS was unable to install one or more resources in the bundle.
    If the BUNDLE resource failed to install in the enabled state, check the bundle parts for the BUNDLE resource. If any of the bundle parts are in the UNUSABLE state, CICS was unable to create the OSGi bundles. Typically, this state indicates that there is a problem with the CICS bundle in zFS. You must discard the BUNDLE resource, fix the problem, and then install the BUNDLE resource again.
  4. Click Operations > Java > OSGi Bundles in the CICS Explorer menu bar to open the OSGI Bundles view. Check the state of the installed OSGi bundles and services in the OSGi framework. The following table summarizes the states:
    BUNDLE BUNDLEPART OSGIBUNDLE OSGISERVICE
    ENABLED ENABLING INSTALLED N/A
    ENABLED ENABLED STARTING N/A
    ENABLED ENABLED ACTIVE ACTIVE
    ENABLED ENABLED ACTIVE INACTIVE
    DISABLED DISABLING STOPPING N/A
    DISABLED DISABLED RESOLVED N/A
    DISABLED UNUSABLE N/A N/A
    • If the OSGi bundle is in the STARTING state, the bundle activator has been called but not yet returned. If the OSGi bundle has a lazy activation policy, the bundle remains in this state until it is called in the OSGi framework.
    • If the OSGi bundles and OSGi services are active, the Java application is ready.
    • If the OSGi service is inactive, CICS detected that an OSGi service with that name already exists in the OSGi framework.

Results

The BUNDLE is enabled, the OSGi bundles are successfully installed in the OSGi framework, and any OSGi services are active. The OSGi bundles and services are available to other bundles in the framework.

What to do next

You can make the Java application available to other CICS applications outside the OSGi framework.