Unable to wire proper bundle with my own bundle in wso2 app server

178 Views Asked by At

I am using wso2 Application Server 5.1.0. I have deployed my own bundle having name demo-service which contains import-package definition in its manifest as below:

>Bundle-SymbolicName = demo-service
Import-Package = javax.sql,org.apache.commons.dbcp;version="[1.4,2)"

I tried to diagnose the most popular "uses conflict" in OSGi world for my case and I found that commons-dbcp_1.4.0.wso2v1.jar and commons-dbcp-1.4.jar both were converted to OSGi bundle by container and exported their packages with version "0.0.0" which can be observed from the output below:

>osgi> packages org.apache.commons.dbcp
org.apache.commons.dbcp; version="0.0.0"<commons-dbcp_1.4.0.wso2v1 [49]>
  compass_2.0.1.wso2v2 [60] imports
  org.wso2.carbon.core_4.1.0 [256] imports
  org.wso2.carbon.registry.core_4.1.0 [377] imports
  org.wso2.carbon.tenant.mgt_2.1.0 [434] imports
  synapse-commons_2.1.1.wso2v3 [528] imports
  synapse-core_2.1.1.wso2v3 [529] imports
org.apache.commons.dbcp; version="0.0.0"<commons_dbcp_1.4_1.0.0 [57]>

According to the requirement of my demo-service bundle it's not able to find org.apache.commons.dbcp;version="[1.4,2)"

Is there any way to export the packages of commons-dbcp-1.4.jar after it gets converted from non-osgi bundle to osgi bundle because I need to make sure that my demo-service bundle should wire with commons-dbcp-1.4.jar..

In brief, any version of thirdparty jar I put in WSO2_HOME\repository\components\lib folder container exports it with version="0.0.0" .. which discourages the main concept for classloading of OSGi

please suggest if any workaround is possible in this case .. :)

Thanks ..

1

There are 1 best solutions below

1
On

When a version is not specified while exporting packages OSGi defaults to version 0.0.0. In this case as it's automatically converting to osgi bundle it might not be having version explicitly specified. Sometimes this also helps to ensure that multiple versions of packages are not present.

In your case as you need to use the packages in the bundle put in repository\components\lib folder you could manually specify the version. The OSGi-fied bundles of the jars you put in repository\components\lib can be found in repository\components\dropins folder. Inside that bundle you will find the OSGi manifest file. In the manifest file manually specify the versions for the required packages under Export-Package category as follows.

org.apache.commons.dbcp;version=1.4.1

Then on startup, it would use these bundles and you should be able to export packages with specified version.