简体   繁体   English

尝试启动osgi包时出现BundleException

[英]BundleException while trying to start an osgi bundle

I'm trying to install & start a bundle from a osgi jar in the filesystem 我正在尝试从文件系统中的osgi jar安装并启动一个包

Bundle bundle = context.installBundle("reference:file:" + fullPath);
bundle.start();

it worked for another simple bundle, but another more complex bundle has 它适用于另一个简单的捆绑包,但另一个更复杂的捆绑包具有

Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"

in its manifest 在它的清单中

this causes the following exception 这会导致以下异常

(org.osgi.framework.BundleException) org.osgi.framework.BundleException: Unresolved constraint in bundle
Unable to resolve 42.0: missing requirement [42.0] osgi.ee; (&(osgi.ee=JavaSE)(version=1.8))

how do I add this capability to my project? 如何将此功能添加到我的项目中? also how would I remove this require from the other project? 我如何从其他项目中删除此要求?

all similiar questions I found didn't answer my question 我发现的所有类似问题都没有回答我的问题

thanks in advance for any answers and for helping me not pull out my hair :) 提前感谢任何答案,并帮助我不拔我的头发:)

Edit: 编辑:

as christian suggested I tried finding the configuration to felix in netbeans, as the felix framework is loaded by netbeans. 正如Christian建议我尝试在netbeans中找到felix的配置,因为felix框架是由netbeans加载的。 I found some configurations inside the maven POM file, but could not use the "org.osgi.framework.system.capabilities" framework property which was mentioned by christian, which I couldn't find in the documentation. 我在maven POM文件中找到了一些配置,但是无法使用christian提到的“org.osgi.framework.system.capabilities”框架属性,我在文档中找不到。 I am putting a bounty as this is really important for me to resolve and is the only thing preventing me from using OSGi as far as I can see 我正在投入一笔赏金,因为这对我来说非常重要,而且就我所见,唯一阻止我使用OSGi的东西

The capability you identified: 您确定的能力:

Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"

is a requirement for the osgi.ee namespace. osgi.ee命名空间的要求。 This is the namespace which defines the execution environment for your framework. 这是定义框架执行环境的命名空间。 The filter then says that you need the execution environment to be JavaSE , and that you need the version attribute to be 1.8 . 然后,过滤器表示您需要执行环境为JavaSE ,并且您需要将version属性设置为1.8 This (unsurprisingly) corresponds to Java SE 8. 这(不出所料)对应于Java SE 8。

As others have indicated, this capability should be provided by the OSGi framework. 正如其他人所指出的,这种能力应该由OSGi框架提供。 You should not need to do anything to get this to happen. 应该做任何事情来实现这一点。 There are two main reasons that this capability would not be present. 这种能力不存在有两个主要原因。

  1. You are using an older, or non SE, version of Java. 您使用的是较旧的或非SE版本的Java。 This could easily happen if your NetBeans launch configuration is not using a Java 8 installation. 如果NetBeans启动配置未使用Java 8安装,则很容易发生这种情况。

  2. You are using a Felix framework which does not understand "new" versions of Java. 您正在使用不了解Java的“新”版本的Felix框架。 This could be because your Felix framework is old (the latest version is 5.6.4 ) or because your Java version is very new (are you using a pre-release Java 9 build?). 这可能是因为您的Felix框架已经过时(最新版本是5.6.4 ),或者因为您的Java版本非常新(您使用的是预发布的Java 9版本吗?)。

This really should just work if you can run a newish Felix framework on top of Java 8. Do you have any more details about your environment? 如果您可以在Java 8之上运行新的Felix框架,那么这真的应该可行 。您是否有关于您的环境的更多详细信息?

Edit: 编辑:

You can see the osgi.ee capability provided by the system bundle as follows: 您可以看到系统包提供的osgi.ee功能,如下所示:

// Get the wiring for the system bundle
BundleWiring wiring = context.getBundle(0).adapt(BundleWiring.class);

// Get the osgi.ee capability for the system bundle
List<Capability> eecaps = wiring.getCapabilities("osgi.ee");

// There must be exactly one capability to show
System.out.println(eecaps.get(0).getAttributes());

This is a capability that needs to be provided by your framework. 这是一个需要由框架提供的功能。 It means that your project needs to run on Java 8. 这意味着您的项目需要在Java 8上运行。

It is configured in the framework property: 它在framework属性中配置:

org.osgi.framework.system.capabilities=osgi.ee; osgi.ee="JavaSE"; version:List<Version>="1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8"

That said normally this is already configured when you for example start the felix distro. 通常说你已经配置好了,例如启动felix发行版。

This is a known felix bug which has been fixed in 2.0.4. 这是已知的felix错误,已在2.0.4中修复。 From http://svn.apache.org/repos/asf/felix/releases/org.apache.felix.bundlerepository-2.0.10/doc/changelog.txt , 来自http://svn.apache.org/repos/asf/felix/releases/org.apache.felix.bundlerepository-2.0.10/doc/changelog.txt

Changes from 2.0.2 to 2.0.4
---------------------------
** Bug
* [FELIX-3097] - LocalRepository is not updated when bundles are
* [FELIX-4571] - NullPointerException when using Repository impl with Aries subsystem impl
* [FELIX-4616] - BundleRepository ResourceComparator violates comparison contract
* [FELIX-4640] - missing (&(osgi.ee=JavaSE)(version=1.8)) when embedding in org.apache.felix.framework

** Improvement
* [FELIX-4812] - BundleRepository can be quite CPU intensive when starting a lot of bundles

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM