Debugging WSO2 Products using OSGI console.

Wso2 products are built collecting several osgi components. It has increased the modularity and extendibility of the WSO2 Carbon based products. But These component get register on the JVM at runtime and could be raise a problem when you develop or testing with products. Thus OSGI console provide way to debug and monitor the component and related service of the product. Here i will demonstrate several command and it’s usage.

  • Start the product with enabling osgi console
  • here i used the APIM 1.10.x version
 
bin/wso2server.sh -DosgiConsole

  1. listadminservices

  2. As you know WSO2 Products are composed of set of components and which are exposed as a SOAP service, we need to find out what are the available services and its endpoints. This command will list down available services like this.
     
    1. ProvisioningAdminService, ProvisioningAdminService, https://rukshan-ThinkPad-T540p:8243/services/ProvisioningAdminService 
    2. MediationSecurityAdminService, MediationSecurityAdminService, https://rukshan-ThinkPad-T540p:8243/services/MediationSecurityAdminService 
    3. CarbonAppUploader, CarbonAppUploader, https://rukshan-ThinkPad-T540p:8243/services/CarbonAppUploader 
    4. OperationAdmin, OperationAdmin, https://rukshan-ThinkPad-T540p:8243/services/OperationAdmin 
    5. JaggeryAppAdmin, JaggeryAppAdmin, https://rukshan-ThinkPad-T540p:8243/services/JaggeryAppAdmin 
    
  3. ss

  4. This will list down the all the bundle or components that are registered with JVM runtime
     
    ex: 
    id	State       Bundle
    0	ACTIVE      org.eclipse.osgi_3.9.1.v20130814-1242
    	            Fragments=1
    1	RESOLVED    org.wso2.carbon.framework.exporter_4.4.1
    	            Master=0
    2	ACTIVE      org.eclipse.equinox.simpleconfigurator_1.0.400.v20130327-2119
    
  5. ss <name>

  6. This command is used to search the component from the above list. it will list all the components which contain the <name> substring.
     
    osgi> ss stub
    "Framework is launched."
    
    
    id	State       Bundle
    152	ACTIVE      org.jaggeryjs.jaggery.app.mgt.stub_0.12.0.M1
    172	ACTIVE      org.wso2.carbon.apimgt.authenticator.oidc.stub_4.3.0.SNAPSHOT
    176	ACTIVE      org.wso2.carbon.apimgt.gateway.stub_4.3.0.SNAPSHOT
    177	ACTIVE      org.wso2.carbon.apimgt.handlers.security.stub_4.3.0.SNAPSHOT
    183	ACTIVE      org.wso2.carbon.apimgt.keymgt.stub_4.3.0.SNAPSHOT
    
  7. b <component-id>

  8. It is used to find the metadata information of the given bundle. component id can be find out with ss command.
     
    osgi> b 198
    org.wso2.carbon.bam.service.data.publisher.stub_4.5.3 [198]
      Id=198, Status=ACTIVE      Data Root=/home/rukshan/apim/1.10.x/wso2am-1.10.0-SNAPSHOT/repository/components/default/configuration/org.eclipse.osgi/bundles/198/data
      "No registered services."
      No services in use.
      Exported packages
        org.wso2.carbon.bam.service.data.publisher.stub.axis2; version="4.5.3"[exported]
        org.wso2.carbon.bam.service.data.publisher.stub.conf; version="4.5.3"[exported]
        org.wso2.carbon.bam.service.data.publisher.stub; version="4.5.3"[exported]
      Imported packages
        javax.xml.namespace; version="0.0.0"<org.eclipse.osgi_3.9.1.v20130814-1242 [0]>
        javax.xml.stream; version="1.0.1"<org.eclipse.osgi_3.9.1.v20130814-1242 [0]>
        org.apache.axiom.om; version="1.2.11.wso2v6"<axiom_1.2.11.wso2v6 [13]>
        org.apache.axiom.soap; version="1.2.11.wso2v6"<axiom_1.2.11.wso2v6 [13]>
        org.apache.axis2; version="1.6.1.wso2v14"<axis2_1.6.1.wso2v14 [14]>
        org.apache.axis2.addressing; version="1.6.1.wso2v14"<axis2_1.6.1.wso2v14 [14]>
        org.apache.axis2.client; version="1.6.1.wso2v14"<axis2_1.6.1.wso2v14 [14]>
        org.apache.axis2.client.async; version="1.6.1.wso2v14"<axis2_1.6.1.wso2v14 [14]>
        org.apache.axis2.context; version="1.6.1.wso2v14"<axis2_1.6.1.wso2v14 [14]>
        org.apache.axis2.databinding; version="1.6.1.wso2v14"<axis2_1.6.1.wso2v14 [14]>
        org.apache.axis2.databinding.utils; version="1.6.1.wso2v14"<axis2_1.6.1.wso2v14 [14]>
        org.apache.axis2.databinding.utils.reader; version="1.6.1.wso2v14"<axis2_1.6.1.wso2v14 [14]>
        org.apache.axis2.description; version="1.6.1.wso2v14"<axis2_1.6.1.wso2v14 [14]>
        org.apache.axis2.engine; version="1.6.1.wso2v14"<axis2_1.6.1.wso2v14 [14]>
        org.apache.axis2.transport; version="1.6.1.wso2v14"<axis2_1.6.1.wso2v14 [14]>
        org.apache.axis2.util; version="1.6.1.wso2v14"<axis2_1.6.1.wso2v14 [14]>
      No fragment bundles
      Named class space
        org.wso2.carbon.bam.service.data.publisher.stub; bundle-version="4.5.3"[provided]
      No required bundles
    
  9. diag <component-id>

  10. This will show the list of missing imported pacKAGES
     
    osgi> diag 190
    reference:file:../plugins/org.wso2.carbon.application.mgt_4.4.7.jar [190]
      Direct constraints which are unresolved:
        Missing optionally imported package javax.activation_[1.1.0,2.0.0).
    
  11. packages <package-name>

  12. This will return all the bundles which use the above package.
     
    osgi> packages org.wso2.carbon.ui         
    org.wso2.carbon.ui; version="4.4.1"<org.wso2.carbon.ui_4.4.1 [452]>
      org.jaggeryjs.jaggery.app.mgt.ui_0.12.0.M1 [153] imports
      org.wso2.carbon.apimgt.authenticator.oidc.ui_4.3.0.SNAPSHOT [173] imports
      org.wso2.carbon.application.mgt.ui_4.4.7 [193] imports
    
  13. install file:<file-path>

  14. this is used to install new bundle to the classpath.
     
    osgi> install file:/home/rukshan/Downloads/mysql-connector-java-5.1.35-bin.jar
    Bundle id is 515
    RegisteredServices   null
    ServicesInUse        null
    Fragments            null
    LoaderProxy          com.mysql.jdbc; bundle-version="5.1.35"
    ClassLoader          null
    Version              5.1.35
    LastModified         1443364020182
    Headers               Ant-Version = Apache Ant 1.8.2
     Built-By = pb2user
     Bundle-Classpath = .
     Bundle-ManifestVersion = 2
     Bundle-Name = Oracle Corporation's JDBC Driver for MySQL
     Bundle-SymbolicName = com.mysql.jdbc
     Bundle-Vendor = Oracle Corporation
     Bundle-Version = 5.1.35
     Created-By = 1.5.0_22-b03 (Sun Microsystems Inc.)
     Export-Package = com.mysql.jdbc;version="5.1.35";uses:="com.mysql.jdbc.log,javax.naming,javax.net.ssl,javax.xml.transform,org.xml.sax",com.mysql.jdbc.jdbc2.optional;version="5.1.35";uses:="com.mysql.jdbc,com.mysql.jdbc.log,javax.naming,javax.sql,javax.transaction.xa",com.mysql.jdbc.log;version="5.1.35",com.mysql.jdbc.profiler;version="5.1.35";uses:="com.mysql.jdbc",com.mysql.jdbc.util;version="5.1.35";uses:="com.mysql.jdbc.log",com.mysql.jdbc.exceptions;version="5.1.35",com.mysql.jdbc.exceptions.jdbc4;version="5.1.35";uses:="com.mysql.jdbc",com.mysql.jdbc.interceptors;version="5.1.35";uses:="com.mysql.jdbc",com.mysql.jdbc.integration.c3p0;version="5.1.35",com.mysql.jdbc.integration.jboss;version="5.1.35",com.mysql.jdbc.configs;version="5.1.35",org.gjt.mm.mysql;version="5.1.35"
     Implementation-Title = MySQL Connector Java
     Implementation-Vendor = Oracle
     Implementation-Vendor-Id = com.mysql
     Implementation-Version = 5.1.35
     Import-Package = javax.net,javax.net.ssl;version="[1.0.1, 2.0.0)";resolution:=optional,javax.xml.parsers, javax.xml.stream,javax.xml.transform,javax.xml.transform.dom,javax.xml.transform.sax,javax.xml.transform.stax,javax.xml.transform.stream,org.w3c.dom,org.xml.sax,org.xml.sax.helpers;resolution:=optional,javax.naming,javax.naming.spi,javax.sql,javax.transaction.xa;version="[1.0.1, 2.0.0)";resolution:=optional,com.mchange.v2.c3p0;version="[0.9.1.2, 1.0.0)";resolution:=optional,org.jboss.resource.adapter.jdbc;resolution:=optional,org.jboss.resource.adapter.jdbc.vendor;resolution:=optional
     Manifest-Version = 1.0
     Specification-Title = JDBC
     Specification-Vendor = Oracle Corporation
     Specification-Version = 4.0
    
    
    StartLevel           1
    BundleData           com.mysql.jdbc_5.1.35
    BundleContext        null
    BundleId             515
    SymbolicName         com.mysql.jdbc
    KeyHashCode          515
    StateChanging        null
    BundleDescription    com.mysql.jdbc_5.1.35
    Framework            org.eclipse.osgi.framework.internal.core.Framework@225d5c92
    ResolutionFailureException org.osgi.framework.BundleException: The bundle "com.mysql.jdbc_5.1.35 [515]" could not be resolved
    Revisions            [com.mysql.jdbc_5.1.35]
    Key                  515
    ProtectionDomain     null
    Location             file:/home/rukshan/Downloads/mysql-connector-java-5.1.35-bin.jar
    State                2
    Bundle                 515|Installed  |    1|com.mysql.jdbc (5.1.35)
    
    osgi> ss sql
    "Framework is launched."
    
    
    id	State       Bundle
    515	INSTALLED   com.mysql.jdbc_5.1.35
    osgi> 
    
  15. uninstall <bundle-id>

  16.              
    osgi> uninstall 514   
    osgi> ss sql
    "Framework is launched."
    
    
    id	State       Bundle
    osgi> 
    
  17. refresh

  18. refresh command will refresh the system components.
     
    osgi> refresh