OSGi Felix应用程序中未解析的JavaFX包 [英] Unresolved JavaFX packages in OSGi Felix Application

查看:352
本文介绍了OSGi Felix应用程序中未解析的JavaFX包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个基于JavaFX和OSGi Felix容器的丰富应用程序。当我的JavaFX启动时,会抛出 org.osgi.framework.BundleException ,表明框架无法连接我的JavaFX包:

I develop a rich application based on JavaFX and the OSGi Felix container. When my JavaFX is started, an org.osgi.framework.BundleException is thrown indicating that the framwork could not wire my JavaFX packages :

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文件:

Here my MANIFEST.MF file :

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

这里是用于启动OSGi框架的VM参数(我使用此插件在Eclipse Luna下运行我的项目):

And here the VM Arguments used to start the OSGi Framework (I run my project under Eclipse Luna, using this plugin) :

-Dosgi.requiredJavaVersion=1.8 -Dorg.osgi.framework.bundle.parent=ext

最后一个参数无效。尽管这篇文章告诉它在Equinox上有效。 ..

The last argument has no effect. In spite of this this article which tell that it works on Equinox...

我找到了一个解决方案,将此选项添加到VM参数中:

I found a solution adding this option to the VM arguments :

-Dorg.osgi.framework.system.packages.extra=javafx.stage

但是这个不是很灵活。

But this is not very flexible.

您认为Felix OSGi实施是否存在问题?它应该只与Equinox一起使用吗?有人可以帮帮我吗?这是正确的方法吗?

Do you think Felix OSGi implementation is the problem ? Should it works only with Equinox ? Anyone can help me ? Is it the right way to do it ?

推荐答案

OSGi规范要求bundle必须导入所有不以java。开头的包。所以你需要导入以javax开头的包。所以现在你需要一个导出器和包的源。 -Dorg.osgi.framework.bundle.parent = ext 为您提供了包的源代码,因为ext classloader loader包含在bundle parent中。但是框架解析器仍然需要有一个包的导出器才能知道bundle的导入是否已正确解析。这就是你需要 -Dorg.osgi.framework.system.packages.extra = javafx.stage 的原因。

The OSGi spec requires that bundles must import all packages that don't start with "java.". So you do need to import packages that start with "javax.". So now you need an exporter and a source for the packages. -Dorg.osgi.framework.bundle.parent=ext gives you a source for the packages since the ext classloader loader is includes in the bundle parent. But the framework resolver still needs to have an exporter for the package to know that the bundle's imports are properly resolved. This is why you need -Dorg.osgi.framework.system.packages.extra=javafx.stage.

这篇关于OSGi Felix应用程序中未解析的JavaFX包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆