gpt4 book ai didi

java - 从 gradle osgi 插件切换到 org.dm.bundle 插件时出错

转载 作者:行者123 更新时间:2023-12-01 10:05:33 25 4
gpt4 key购买 nike

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

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

出现错误,因此导致 bundle 在 felix 中未处于 Activity 状态,并且无法启动。

为什么 bundle 需要 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 (并不真正属于那里)

最佳答案

问题似乎出在quartz包的 list 中,它在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 规范在这种情况下应该发生什么,我试图在规范中找到答案,但我只是找不到任何特定于这种情况的内容...我的解释是 bundle 仍然应该导出org.quartz.commonj包,因为规范只说可选要求不能阻止bundle的接线得到满足,它没有说明依赖于导出包的任何内容据我所知,关于可选导入。

现在的问题是为什么它可以与 osgi 插件一起使用,该插件仅调用 Bnd 来创建 list ,但不能与 org.dm.bundle,它也调用 Bnd,但要创建整个 jar...

在 Felix 中运行时,我可以看到 org.quartz.commonj 包已由quartz 包成功导出,并且可用于连接到其他包,所以我认为应该允许这样做去工作。

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

关于java - 从 gradle osgi 插件切换到 org.dm.bundle 插件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36501151/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com