Troubleshooting OSGi applications on Liberty

You can use the osgiAppConsole-1.0 feature to determine and analyze the OSGi applications-related issues.

Before you begin

To use the osgiAppConsole-1.0 feature, you must have Liberty and the osgiAppConsole-1.0 feature installed:
  • Install the latest version of Liberty with the OSGi application programming model capabilities. You can install Liberty either by using one of the zip install packages (ZIP file) or by extracting the Java archive (JAR) package. For more information about installing Liberty, see Installing Liberty.
  • The osgiAppConsole-1.0 feature is available as part of the downloaded (ZIP) compressed files. However, if the feature is not already installed in the run time, then install the feature from the Liberty Repository using the following command:
    bin\installUtility install osgiAppConsole-1.0
After Liberty and the feature installation are complete, you are ready to configure and use the feature.

Procedure

  • Configure the osgiAppConsole-1.0 feature in the server.xml file.
    
    <featureManager>
      <feature>osgiAppConsole-1.0</feature>
    </featureManager>
  • Add the security configurations. The following example shows a sample security configuration with an admin role that uses basic authorization and https security.
    
    <httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>
    <keyStore id="defaultKeyStore" password="Liberty"/>
    <quickStartSecurity userName="admin" userPassword="password"/>

What to do next

  • When you start the server or add the feature to a running server, you might see a few messages as given in the following example:
    [AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:9080/osgi/http/
    [AUDIT   ] CWWKN2000A: HTTP Whiteboard context root added: http://localhost:9080/osgi/http
    [AUDIT   ] CWWKN2000A: HTTP Whiteboard context root added: http://localhost:9080/osgi/http/shared
    [AUDIT   ] CWWKN2050A: OSGi Application console added at: http://localhost:9080/osgi/http/shared/system/console
    [AUDIT   ] CWWKN2000A: HTTP Whiteboard context root added: http://localhost:9080/osgi/http/MyWab.app
    [AUDIT   ] CWWKN2050A: OSGi Application console added at: http://localhost:9080/osgi/http/MyWab.app/system/console
    [AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:9080/MyWab.war/
    The OSGi Application console added at message shows the available console capabilities. In the previous example, a sample OSGi application, MyWab.app, is deployed. You can see the console entries for the MyWab.app application and the shared bundle space, which contains all bundles that are shared between applications on the same server.
  • When you access the URL, you are redirected to the https page and asked to sign in using the credentials that are configured in the server.xml. After you sign in, you can view the console page of your OSGi application.
In the following example, the Felix Web console is used to show you how the console feature is used. For more information about the Felix web console, see Apache Felix Web Console.
image of Felix Web Console Bundlesb
In the Felix console, you will notice the following points:
  • You can see a few extra bundles in the view for your application. They are a mixture of the environment bundles in the previous image (IDs 0 and 161) and the console bundles (IDs 163 and 164).
    Avoid: You must not make lifecycle actions on any bundles to avoid unwanted results because Liberty manages the lifecycle actions on all the bundles.
  • The last bundle to mention in the previous example is the OSGi application bundle, MyWab (162).
    Image of a drilled down bundle on Felix Web Console
  • You can drill down on the details of each bundle by clicking the name of the bundle. In the example, you can see a number of packages that are provided by other bundles in the system.
  • You can also view the service dependencies so that you can see the services that your application is using and the services that you provide, although this view is not shown in the previous example.