Reputation: 71
I'm trying to use Apache POI to work with excel sheet. The application should support .xlsx format files.
For this I am installing these two dependency as bundles in Jboss FUSE:
<bundle start-level="15">wrap:mvn:org.apache.poi/poi/3.5-FINAL</bundle>
<bundle start-level="15">wrap:mvn:org.apache.poi/poi-ooxml/3.15</bundle>
However I get an error saying that it finds below package in both the above bundles. Hence there is an ambiguity.
org.apache.poi.ss.usermodel
ERROR:
Unable to resolve bundle revision wrap_mvn_org.apache.poi_poi-ooxml_3.15 [2133.0] because it exports package 'org.apache.poi.ss.usermodel' and is also exposed to it from bundle revision wrap_mvn_org.apache.poi_poi_3.5-FINAL [2094.0]
As a matter of fact:
Is there any workaround in FUSE to resolve the issue arising due to same package name in two dependencies.
Upvotes: 0
Views: 620
Reputation: 35
The poi bundle managed by servicemix worked for me also. Apache commons collection 4 is required
[Active ] [ ] [ ] [ 80] Apache Commons Collections (4.1.0)
[Active ] [ ] [ ] [ 80] Apache ServiceMix :: Bundles :: poi (3.15.0.1)
Upvotes: 0
Reputation: 71
I used pre-existing OSGi bundles of Apache POI, eg this one maintained by Apache ServiceMix as suggested by @Gagravarr and it worked.
Learning for me: While working on osgi, I should be first looking at apache service mix bundles.
Upvotes: 3
Reputation: 19606
A simple solution would be to create one bundle that contains the contents of both poi bundles. You can achieve this by using the maven-bundle-plugin and the Embed-Dependency option.
Upvotes: 1
Reputation: 1217
Such kind of problem in OSGi has its own name: Split-package issue, and it has no straight-forward solution. While in Java SE such approach is used in some frameworks, in OSGi it is not supported by the core concept of modules, and I doubt it will ever be.
Usually, such problem is solved by repackaging modules in such way that the packages are not splat beyond the modules. You can find such an approach applied in different frameworks, which provide a separate artifact for using in OSGi. You may do it by your own, by means of some maven plugins like maven-bundle-plugin.
Alternatives to consider may be to:
embed such modules into the bundle which uses it (see http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html#embedding-dependencies)
or export them via system package (see http://felix.apache.org/documentation/subprojects/apache-felix-framework/apache-felix-framework-configuration-properties.html)
But be careful: usually such approaches break the concept of modularity and have it's own risks.
Upvotes: 1