我开发了一个基于 JavaFX 和 OSGi Felix 容器的丰富应用程序。当我的 JavaFX 启动时,org.osgi.framework.BundleException抛出表明框架无法连接我的 JavaFX 包:
ERROR: Bundle app-impl-bundle [3] Error starting eclipse-project:T:\workspace\fast-osgi\app-impl-bundle\ (org.osgi.framework.BundleException: Unresolved constraint in bundle app-impl-bundle [3]: Unable to resolve 3.0: missing requirement [3.0] osgi.wiring.package; (&(osgi.wiring.package=javafx.stage)(version>=2.2.0)))
这是我的 MANIFEST.MF 文件:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: app-impl-bundle
Bundle-SymbolicName: app-impl-bundle
Bundle-Version: 1.0.0.qualifier
Require-Bundle: app-bundle;bundle-version="0.0.1"
Bundle-Activator: com.mycompany.app.impl.Activator
Import-Package: javafx.stage;version="2.2.0",
javax.xml.parsers,
org.osgi.framework;version="1.8.0",
org.w3c.dom,
org.xml.sax
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: .,
target/lib/log4j-1.2.17.jar
这里的 VM 参数用于启动 OSGi 框架(我在 Eclipse Luna 下运行我的项目,使用这个插件 https://code.google.com/p/felix-eclipse/) :
-Dosgi.requiredJavaVersion=1.8 -Dorg.osgi.framework.bundle.parent=ext
最后一个参数没有效果。尽管如此本文 https://www.eclipse.org/forums/index.php/t/970283/这表明它适用于 Equinox...
我找到了一个解决方案,将此选项添加到虚拟机参数中:
-Dorg.osgi.framework.system.packages.extra=javafx.stage
但这不太灵活。
您认为 Felix OSGi 的实现是问题所在吗?它应该只适用于 Equinox 吗?任何人都可以帮助我吗?这是正确的做法吗?