Hi Akila,

This very detailed explanation is most helpful for a non-Java programmer like 
me. I conclude that the compile time dependency can be overridden by the 
run-time actual dependency packaging (always assuming compatible APIs, clearly 
all bets are off if that is not honoured).

Thanks a lot, Shaheed

From: Akila Ravihansa Perera [mailto:raviha...@wso2.com]
Sent: 01 December 2015 14:30
To: dev
Subject: Re: File handle leak in Thrift

Hi Shaheed,

Let me clarify few things here, even though you might be already aware.

 - Maven dependency versions that you specify in your component's pom.xml for 
external dependencies should match the dependency that is actually bundled into 
the distribution via p2 feature management.

- You need to make sure that any external dependency version that you "need" is 
actually bundled by the feature which installs your component. There is 
absolutely no guarantee that dependencies you define in your component's 
pom.xml will be available in the run time.

- Any external library that you wish to include in Stratos must be an OSGi 
bundle OR you need to embed those libraries into your component. A component in 
Carbon world is always an OSGi bundle.

- If you are having external dependencies which are installed as OSGi bundles, 
it is always recommended to have OSGi import definition with required version 
range in maven-bundle-plugin. If you have correct import statements then you 
don't need to worry about having multiple jars of the same library with 
different versions.

I can think of 2 ways to resolve your issue;

1. Create an OSGi bundle of libthrift 0.9.3 library and bundle it into your 
feature (you can use this [1] maven dependency).
Checkout  [2, 3] for more information about Carbon feature 
management/installation via pom.xml.

2. This is the simplest solution. Embed libthrift 0.9.3 dependency to your OSGi 
bundle. Have a look at [4] for more information. This would make the embedded 
library available to the Java class loader which loads your OSGi bundle (your 
component).

[1] 
http://mvnrepository.com/artifact/org.apache.servicemix.bundles/org.apache.servicemix.bundles.libthrift/0.9.3_1

[2] https://docs.wso2.com/display/Carbon420/Installing+Features+using+pom+Files

[3] 
http://wso2.com/library/tutorials/2014/03/how-to-create-a-feature-from-wso2-carbon-component/

[4] http://www.sergiolopes.eu/2014/04/adding-jars-to-osgi-bundles-with-maven/

Hope this helps.

Thanks.

Reply via email to