简体   繁体   中英

maven-bundle-plugin Creates unexpected Import-Package content

I build all my bundles using maven-bundle-plugin and after some tests with pax:provision I found that it is creating a Import-Package=org.osgi.framework;version="[1.8,0)" on all bundles and at the moment of installing the bundles in Felix then I get all my bundles unresolved because of org.osgi.framework.BundleException: Unresolved constraint in bundle com.domain.mybundle [55]: Unable to resolve 55.0: missing requirement [55.0] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.8.0)(!(version>=2.0.0))) org.osgi.framework.BundleException: Unresolved constraint in bundle com.domain.mybundle [55]: Unable to resolve 55.0: missing requirement [55.0] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.8.0)(!(version>=2.0.0))) .

Why is maven-bundle-plugin creating this header if I have no direct dependency to that package. I also tried to add the dependency:

<dependency>
  <groupId>org.apache.felix</groupId>
  <artifactId>org.apache.felix.framework</artifactId>
  <version>4.6.0</version>
</dependency>

And it still uses the version 1.8.0 . Any idea why?

UPDATE

Checking again, the bundles do use the org.osgi.framework in the Activator. but this class org.osgi.framework.BundleActivator comes from the bundle:

<dependency>
  <groupId>org.osgi</groupId>
  <artifactId>org.osgi.core</artifactId>
  <version>4.3.1</version>
  <scope>provided</scope>
  <optional>true</optional>
</dependency>

So again, why isn't the maven-bundle-plugin using the version 4.3.1 instead of 1.8.0 ? And in other bundles it uses version 1.6.2 .

UPDATE 20-3-2015

This is the exception I receive after executing mvn pax:provision

org.osgi.framework.BundleException: Unresolved constraint in bundle org.classdomain.per
sistence [47]: Unable to resolve 47.0: missing requirement[47.0] osgi.wiring.package; 
(&(osgi.wiring.package=org.osgi.framework)(version>=1.8.0)(!(version>=2.0.0)))ERROR: 
Bundle org.classdomain.persistence [47] Error starting file:bundles/org.classdomain.per
sistence_0.1.0.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle
 org.classdomain.persistence [47]: Unable to resolve 47.0: missing requirement [47.0] o
sgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.8.0)(!(versio
n>=2.0.0))))

        at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4002)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2045)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1299)
        at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304)
        at java.lang.Thread.run(Thread.java:745)

Definitely, seems like this exception only happens when using mvn pax:provision , if I install the same bundles in a stand alone Felix instance then every thing works as expected.

The Import-Package statements are built according to the defined package versions in the libraries you use. In your case you have a dependency to org.apache.felix.framework which defines these exports (eg org.osgi.framework version 1.8) in its Manifest.

If you only have a depenency to org.osgi.core 4.3.1 then the package org.osgi.framework should be defined with version 1.6. So this should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM