Deploy an OSGi application as a business-level application
Import an OSGi application as an enterprise bundle archive (EBA) asset, then add the asset to a business-level application by creating a composition unit. Optionally, add a composite bundle extension to the composition unit.
This topic assumes that we have already created an enterprise OSGi application packaged as an EBA file, for example as described in Create an OSGi application. We might also have developed a composite bundle extension, as described in Extending a deployed OSGi application.
In addition to specifying the configuration information for the EBA asset through the following procedure, we can also change it later as described in Modify the configuration of an OSGi composition unit. For example, if you update a bundle in an EBA asset, or replace a composite bundle extension, you might introduce a resource that requires additional configuration, such as a new or changed Blueprint resource reference, or security role mapping.
To deploy an OSGi application in WebSphere Application Server, you import your OSGi application (EBA file) as an asset and create an empty business-level application. You then add a composition unit to the business-level application. This composition unit consists of the new EBA asset plus configuration information for the context roots, virtual hosts, security role mappings, and web application or Blueprint resource bindings for the OSGi application. The composition unit can also include composite bundle extensions.
- An EBA file can be imported into only one asset.
- An EBA asset can be added to only one business-level application.
- One or more composite bundle extensions can be added to a composition unit.
A business-level application is scoped to cell scope, therefore only one instance of an OSGi application can be deployed in a cell.
This topic describes the specific task of deploying an OSGi application and any composite bundle extensions as a business-level application. The more generalized task of creating any business-level application is described in Create business-level applications.
Each step can be completed using either the administrative console or wsadmin commands. You can also create an empty business-level application or add a composition unit using programming.
Demonstration of this task (4 min)
- Import the EBA file as an asset.
You can import the asset before or after we create the empty business-level application. An EBA file can be imported into only one asset.
To import the EBA file using the administrative console, navigate to Applications > New Application > New Asset. For more information, see Import assets.
To import the EBA file using mportAsset command, enter (for example) the following command:
AdminTask.importAsset(["-storageType", "FULL", "-source", com.ibm.ws.eba.helloWorldService.eba])For more information, see the step "Import assets to the configuration" in topic Set up business-level applications wsadmin.
- When you import the EBA file as an asset, it is checked for any bundle dependencies. If the OSGi application has dependencies on bundles that are not included in the EBA file, the dependencies are resolved against any configured bundle repositories. Asset registration cannot complete unless all missing dependencies are available from configured bundle repositories.
- When asset registration completes, if the asset requires bundles to be downloaded from bundle repositories, a warning message is displayed telling you to save the changes to the master configuration after completing the asset import. When you save changes, the missing dependencies are downloaded from the configured bundle repositories.
- If the asset uses Java™ 2 security, the security permissions are displayed. This information comes from the META-INF/permissions.perm file for the application. For more information, see Java 2 security and OSGi Applications.
- Do not add the asset to a business-level application until the bundle download has completed. You can view the download status of the bundles from the administrative console, or by calling the areAllDownloadsComplete () method of the BundleCacheManager MBean. See Interacting with the OSGi bundle cache.
- Create an empty business-level application.
To create an empty business-level application using the administrative console, navigate to Applications > New Application > New Business Level Application. For more information, see the step "Create an empty business-level application" in topic Create business-level applications with the console.
To create an empty business-level application using the createEmptyBLA command, enter (for example) the following command:
AdminTask.createEmptyBLA('[-name "helloWorld" -description "helloWorld OSGi sample"]')For more information, see the step "Create an empty business-level application" in topic Set up business-level applications wsadmin.To create an empty business-level application using programming, see Create an empty business-level application using programming.
- Add the EBA asset to the business-level application as a composition unit.
An EBA asset can be added to only one business-level application. An OSGi composition unit consists of an EBA asset, (optionally) one or more composite bundle extensions, and some or all of the following configuration information:
- Mappings from the composition unit to a target application server, web server, or cluster.
- Configuration of the session manager, context roots or virtual hosts of the application.
- Mappings from enterprise beans to JNDI names.
- Bindings to any associated web applications or blueprint resource references.
- Mappings from security roles to particular users or groups.
To add the asset to the business-level application as a composition unit, use one of the following methods:
- Add an EBA asset to a composition unit using the administrative console.
- Add an EBA asset to a composition unit by using wsadmin commands.
- Add a composition unit using programming.
- Optional: Add a composite bundle as an extension to the composition unit.
After you import the enterprise bundle archive (EBA) file for the OSGi application as an asset, we can update versions of existing bundles but we cannot add extra bundles to the asset. However, after we have added the asset as a composition unit to a business-level application, we can extend the business-level application by adding one or more composite bundles to the composition unit.
- Save the changes to the master configuration.
If we are using wsadmin commands, enter the following command:
AdminConfig.save()
What to do next
We are now ready to start the business-level application.
Subtopics
- Add an EBA asset to a composition unit using the administrative console
Use the administrative console to add a composition unit that consists of a previously-imported EBA asset plus configuration information. The configuration information can include HTTP session management, context roots, virtual hosts, security roles, run-as roles, JNDI mappings for Session enterprise beans, JNDI mappings for EJB references, and web application or Blueprint resource reference bindings for the OSGi application.
- Add an EBA asset to a composition unit by using wsadmin commands
You can use the addCompUnit command and the AdminConfig commands to add a composition unit that consists of a previously-imported enterprise bundle archive (EBA) asset plus configuration information. The configuration information can include HTTP session management, context roots, virtual hosts, security roles, run-as roles, JNDI mappings for Session enterprise beans, JNDI mappings for EJB references, and web application or Blueprint resource reference bindings for the OSGi application.
Parent topic: Deploy OSGi applications
Related concepts
Assets Business-level applications Composition units Enterprise bundle archive installation Enterprise bundle archives Provisioning for OSGi applications Java 2 security and OSGi Applications
Related tasks
Develop a composite bundle Create an empty business-level application using programming Add a composition unit using programming Interacting with the OSGi bundle cache Secure OSGi applications
Converting an enterprise application to an OSGi application