【问题标题】:Error when switching from gradle osgi plugin to org.dm.bundle plugin从 gradle osgi 插件切换到 org.dm.bundle 插件时出错
【发布时间】:2016-04-08 13:41:55
【问题描述】:

在quartz-sample-nested-jars 示例中:

https://github.com/paulvi/osgi-run/tree/master/osgi-run-test/quartz-sample-nested-jars

有错误,所以结果包在 felix 中不是 ACTIVE,无法启动。

为什么捆绑包需要 osgi.wiring.package=commonj.work?这是从哪里来的?如果它是您项目的 Gradle 依赖项,osgi-run 会将其添加到运行时...也许您只需要在 Gradle deps 中添加一个 osgiRuntime 'org:commonj.work:version' 声明?

完整日志

# parseClassFile(): path=org/xml/sax/ErrorHandler.class resource=:file:/C:/Program%20Files/Java/jdk1.8.0_74/jre/lib/rt.j
ar!/org/xml/sax/ErrorHandler.class:
:quartz-sample-nested-jars:createOsgiRuntime
> Building 83% > :quartz-sample-nested-jars:runOsgi

:quartz-sample-nested-jars:runOsgi
org.osgi.framework.BundleException: Unable to resolve com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0): mis
sing requirement [com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0)] osgi.wiring.package; (osgi.wiring.packa
ge=commonj.work) Unresolved requirements: [[com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0)] osgi.wiring.p
ackage; (osgi.wiring.package=commonj.work)]
ERROR: Bundle com.athaydes.gradle.osgi.quartz-sample-nested-jars [6] Error starting file:/D:/Workspaces/GitHub/osgi-run/
osgi-run-test/quartz-sample-nested-jars/build/osgi/bundle/quartz-sample-nested-jars-1.0.jar (org.osgi.framework.BundleEx
ception: Unable to resolve com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0): missing requirement [com.athay
des.gradle.osgi.quartz-sample-nested-jars [6](R 6.0)] osgi.wiring.package; (osgi.wiring.package=commonj.work) Unresolved
 requirements: [[com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0)] osgi.wiring.package; (osgi.wiring.packag
e=commonj.work)])
        at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4111)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2117)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1371)
        at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
        at java.lang.Thread.run(Thread.java:745)
____________________________
Welcome to Apache Felix Gogo

> Building 83% > :quartz-sample-nested-jars:runOsgilb
g! g! g! START LEVEL 1
   ID|State      |Level|Name
    0|Active     |    0|System Bundle (5.4.0)|5.4.0
    1|Active     |    1|c3p0 (0.9.1.1)|0.9.1.1
    2|Active     |    1|Apache Felix Gogo Command (0.16.0)|0.16.0
    3|Active     |    1|Apache Felix Gogo Runtime (0.16.2)|0.16.2
    4|Active     |    1|Apache Felix Gogo Shell (0.12.0)|0.12.0
    5|Active     |    1|quartz (2.2.1)|2.2.1
    6|Installed  |    1|com.athaydes.gradle.osgi.quartz-sample-nested-jars (1.0.0)|1.0.0
    7|Active     |    1|slf4j-api (1.6.6)|1.6.6
    8|Resolved   |    1|slf4j-simple (1.6.6)|1.6.6
> Building 83% > :quartz-sample-nested-jars:runOsgistart 6
org.osgi.framework.BundleException: Unable to resolve com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0): mis
sing requirement [com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0)] osgi.wiring.package; (osgi.wiring.packa
ge=commonj.work) Unresolved requirements: [[com.athaydes.gradle.osgi.quartz-sample-nested-jars [6](R 6.0)] osgi.wiring.p
ackage; (osgi.wiring.package=commonj.work)]
> Building 83% > :quartz-sample-nested-jars:runOsgi

公开问题https://github.com/renatoathaydes/osgi-run/issues/36(不属于那里)

【问题讨论】:

    标签: java gradle osgi bundle


    【解决方案1】:

    问题似乎出在石英包的清单中,它包含在Export-Package 指令中:

    org.quartz.commonj;
    uses:="commonj.work,javax.naming,org.quartz.spi,org.slf4j";
    version="2.2.1"
    

    然后,在Import-Package 指令中,这个:

    commonj.work;resolution:=optional
    

    所以,为了让这个包导出org.quartz.commonj,它需要导入commonj.work,但这是一个可选的导入...

    我不确定 OSGi 规范说它应该在这种情况下发生什么,我试图在规范中找到,但我找不到任何特定于这种情况的东西......我的解释是捆绑包应该仍然导出org.quartz.commonj 包,因为规范只说optional 要求不能阻止满足捆绑包的布线,据我所知,它没有说明依赖可选导入的导出包。

    现在的问题是为什么它可以与osgi 插件一起使用,它只调用Bnd 来创建清单,但不适用于org.dm.bundle,它也调用Bnd,而是创建整个jar。 .

    在 Felix 中运行时,我可以看到 org.quartz.commonj 包已由石英捆绑包成功导出,并可用于连接到其他捆绑包,因此我认为应该允许这样做。

    我建议使用org.dm.bundle 或直接使用Bnd 填充错误。我相信他们将能够给出更可靠的答案,并且如果他们认为合适,请修复他们可能遇到的任何可能导致此问题的错误。

    【讨论】:

      【解决方案2】:

      不是 OSGI 导出,我不能肯定地说,但我怀疑包“commonj.work”不应该在这里https://github.com/quartz-scheduler/quartz/blob/master/quartz/pom.xml#L232

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-10-11
        • 2016-12-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多