【发布时间】:2015-05-19 05:51:42
【问题描述】:
我使用maven-bundle-plugin 构建所有捆绑包,在使用pax:provision 进行一些测试后,我发现它正在所有捆绑包上创建Import-Package=org.osgi.framework;version="[1.8,0)",并且在Felix 中安装捆绑包时,我的所有捆绑包都未解决因为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)))。
如果我没有直接依赖于那个包,为什么maven-bundle-plugin 创建这个头文件。我也尝试添加依赖:
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>4.6.0</version>
</dependency>
它仍然使用版本1.8.0。知道为什么吗?
更新
再次检查,捆绑包确实使用了激活器中的org.osgi.framework。但是这个类 org.osgi.framework.BundleActivator 来自捆绑包:
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.1</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
那么,为什么maven-bundle-plugin 不使用版本4.3.1 而不是1.8.0?在其他捆绑包中,它使用版本1.6.2。
2015 年 3 月 20 日更新
这是我在执行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)
当然,这个异常似乎只在使用 mvn pax:provision 时发生,如果我在独立的 Felix 实例中安装相同的包,那么一切都会按预期工作。
【问题讨论】:
标签: java maven osgi apache-felix maven-bundle-plugin