Web Application Deployment

This chapter describes how to deploy web applications with OSGi bundles included.

If a web application deployed by JEUS utilizes OSGi bundles as libraries, it is possible to package these bundles along with the application and install them in the designated OSGi framework during the deployment process. To accomplish this, the following tasks need to be performed when packaging the application.

  1. Place the bundles to use in the application.

  2. Specify the configuration related to OSGi in jeus-web-dd.xml.

    Example of jeus-web-dd.xml configuration
    <?xml version="1.0"?>
    <jeus-web-dd xmlns="http://www.tmaxsoft.com/xml/ns/jeus">
        ....
        <osgi>
            <!-- Framework Name -->
            <framework-name>fwk-0</framework-name>
            <!-- Initial Bundles Directory Settings -->
            <install-initial-bundles>true</install-initial-bundles>
            <initial-bundles-directory-location>WEB-INF/osgi</initial-bundles-directory-location>
            <default-start-level>11</default-start-level>
            <fail-on-error>true</fail-on-error>
            <!-- Class Loading Delegation Settings -->
            <class-loading-delegation>
                <application-bundle>
                    <bundle-symbolic-name>jeus.osgi.hello-api</bundle-symbolic-name>
                    <version>1.0.0.Final</version>
                </application-bundle>
            </class-loading-delegation>
        </osgi>
        ....
    </jeus-web-dd>

    The configuration items are as follows.

    • Framework Name

      Specifies the name of OSGi framework to use in the web application.

    • Configuration items for Initial Bundles Directory

      In JEUS, the directory within a web application where bundles are located is referred to as the Initial Bundles Directory. You can control the location of this directory and its functionality by using configuration items of eus-web-dd.xml. If the initial bundles directory is specified for use, the designated location is checked and the included bundles are installed in the specified OSGi framework. Please note that when deploying the web application, the bundles included within it will be installed in the specified OSGi framework. Conversely, when undeploying the application, these bundles will be removed.

      The configurable items for the initial bundles directory are as follows.

      Item Description

      Install Initial Bundles

      Decides whether to install bundles in the initial bundles directory when deploying the web application.

      Initial Bundles Directory Location

      Specifies the location of the initial bundles directory.

      Default Start Level

      Specifies the default start level for the initial bundles directory.

      Fail On Error

      Decides whether to regard the failed installation of bundles as an error.

    • Configuration items for Class Loading Delegation

      These configuration items are set up when the web application needs to reference classes from the bundles installed in the OSGi framework. By specifying the bundle symbolic name and version of the desired bundles, the application can utilize the referenced classes. Multiple bundles can be specified for referencing, and in such cases, the search for the class is performed in the specified order.

      1. The OSGi bundles are searched for the classes or resources only if they cannot be found in the hierarchical structure of JEUS class loader.

      2. If a bundle containing classes referenced by the web application is updated, an class-related error may occur in the web application. In this case, you must redeploy or reload the web application. To mitigate the occurrence of this error, it is recommended to use API bundles for reference because they are relatively little changed.

If the application including the OSGi bundles is deployed, the related configuration can be checked by using the console commands.

Using the console tool

By utilizing console commands to retrieve detailed information about the web application, you can also access the configuration details of the associated OSGi.

[MASTER]domain1.adminServer>application-info -server server1 -id hello-osgi.war -type WAR
There are no EJBs in this module.
General information about the web module [hello-osgi].
================================================================================
+-------------+---------------------+--------------+---------------------------+
| Module Name |  Unique Module Name | Context Path |   Target Session Cluster  |
+-------------+---------------------+--------------+---------------------------+
| hello-osgi  | hello-osgi          | /hello-osgi  |                           |
+-------------+---------------------+--------------+---------------------------+
================================================================================

Servlets
================================================================================
+------------+-------------+-------+-------+-----------+---------+-------------+
|    Name    |    Class    | State | Count | Attribute | RegType | URLPatterns |
+------------+-------------+-------+-------+-----------+---------+-------------+
| appServlet | org.springf | READY |     0 | SYNC      | WEB_XML | /           |
|            |ramework.web |       |       |           |         |             |
|            |.servlet.Dis |       |       |           |         |             |
|            |patcherServl |       |       |           |         |             |
|            |et           |       |       |           |         |             |
+------------+-------------+-------+-------+-----------+---------+-------------+
================================================================================
...

...
OSGi Application Information
================================================================================
+--------------------------+---------------------------------------------------+
|      Attribute Name      |                       Value                       |
+--------------------------+---------------------------------------------------+
| Framework Name           | framework-0                                       |
+--------------------------+---------------------------------------------------+
| Install Initial Bundles  | true                                              |
+--------------------------+---------------------------------------------------+
| Initial Bundles          | /home/user/workspace/jeus/jeus/target/jeus/doma   |
|Directory Location        |ins/osgi/servers/server1/.workspace/deployed/hello |
|                          |-osgi.war/hello-osgi_war___/WEB-INF/osgi           |
+--------------------------+---------------------------------------------------+
| Default Start Level      |                                                11 |
+--------------------------+---------------------------------------------------+
| Fail On Error            | true                                              |
+--------------------------+---------------------------------------------------+
================================================================================

Delegate Bundles
================================================================
+------------------------------------------------+-------------+
|              Bundle Symbolic Name              |   Version   |
+------------------------------------------------+-------------+
| jeus.osgi.hello-api                            | 1.0.0.Final |
+------------------------------------------------+-------------+
================================================================

EJBs
================================================================================
+-----------+------+-------------------------+---------------------------------+
| Bean Name | Type |    Local Export Name    |        Remote Export Name       |
+-----------+------+-------------------------+---------------------------------+
(No data available)
================================================================================
[MASTER]domain1.adminServer>