Creating an OSGi application project

An OSGi Application Project (EBA) groups together a set of bundles. The application can consist of different OSGi bundles types.

Before you begin

Ensure that you have set up the development environment.

About this task

If you are using the CICS Explorer SDK, you can refer to theCICS Explorer and CICS Explorer SDK help, which provides full details on how you can complete each of the following steps to develop and package web applications.

If you are using a build toolchain such as Maven or Gradle, you can use CICS-provided artifacts on Maven Central to define Java dependencies.

Procedure

  1. If you're using the CICS Explorer SDK, set up a target platform for your Java™ development, using the CICS® TS V5.3 with Liberty and PHP template. You might get a warning that the target is a newer version than the current Eclipse installation, but you can ignore this warning message.
  2. Create an OSGi bundle project for your application.
    • If you're using the CICS Explorer SDK, the target platform effectively makes the packages available, so you must include the appropriate Import statements in the bundle manifest. A web-enabled OSGi bundle project is the bundle equivalent of a dynamic web project. You can use a web-enabled OSGi bundle project to deploy an application within an OSGi Application Project (an Enterprise Bundle Archive, or EBA file). You can mix web-enabled OSGi bundle projects (WAB files) and non-web-enabled OSGi bundle projects in your OSGi Application Project. A web-enabled OSGi bundle project would typically implement the front end of the application, and interact with the non-web OSGi bundles, which contain the business logic.
    • For Maven users, create a Maven project. In the pom.xml file, specify <packaging>bundle</packaging> and the following dependency:
      <dependency>
        <groupId>net.wasdev.maven.tools.targets</groupId>
        <artifactId>liberty-target</artifactId>
        <version><your_liberty_version></version>
        <type>pom</type>
        <scope>provided</scope>
      </dependency>
      Instead of specifying the dependency above, you can start with an OSGi bundle archetype, for example, the osgi-web31-liberty artifact, and modify it. Then declare dependencies on CICS-provided artifacts.
    • For Gradle users, create a Gradle-enabled OSGi project using the BND Gradle Plugins, and then declare dependencies on CICS-provided artifacts.
  3. Develop your web application. You can use the JCICS API to access CICS services and JDBC to connect to DB2®. The CICS Explorer SDK includes examples of web components and OSGi bundles that use JCICS and DB2. Create OSGi bundles that use JCICS to separate the business from the presentation logic. You can also use semantic versioning in OSGi bundles to manage updates to the business logic of the application. For each WAB or OSGi bundle that uses DB2 through the JDBC DriverManager interface, include an Import-Package header for com.ibm.db2.jcc in the bundle manifest. Omitting this import will result in the error message java.sql.SQLException: No suitable driver found for jdbc:default:connection. The import is not required when using the JDBC DataSource interface.
  4. Optional: If you want to authenticate users of the Web application, create a web.xml file in the web project to contain a security constraint. The CICS Explorer SDK includes a template for this file that contains the correct information for CICS. See Authenticating users in a Liberty JVM server for further information.
  5. Create an OSGi Application Project that references your OSGi bundles.
  6. Create a CICS bundle project that references the OSGi Application Project. You can also add definitions and imports for CICS resources. Each CICS bundle contains an ID and version so you can manage changes in a granular way.
  7. Optional: Add a URIMAP and TRANSACTION resource to a CICS bundle if you want to map inbound web requests from a URI to run under a specific transaction. If you do not define these resources, all work runs under a supplied transaction, which is called CJSA. These resources are installed dynamically and managed as part of the bundle in CICS.

Results

You set up your development environment, created a OSGi web application, and packaged it for deployment.

What to do next

When you are ready to deploy your application, export the CICS bundle projects to zFS. The referenced projects are built and included in the transfer to zFS. Alternatively, you can follow a development deployment model by exporting the application as an EBA file and deploying it to the dropins directory of a running Liberty JVM server. You should be aware that Security and other qualities of service are not configurable using dropins.