如何在osgi中配置系统范围的软件包? [英] How to configure a system-wide package in osgi?

查看:119
本文介绍了如何在osgi中配置系统范围的软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为某些捆绑软件提供一个库.该库利用RMI,因此(至少据我所知)需要使用系统类加载器才能工作(我试图"osgi-fy"该库,这会在运行时导致classcastexceptions).因此,我要做的是从使用该库的包中删除依赖项,并使用jars.extra.classpath属性(包含在eclipse项目的build.properties中)中的库进行编译.

I need to made available a library to some bundles. This library makes use of RMI, so it needs (as far as I know, at least) to use the system class loader in order to work (I tried to "osgi-fy" the library, which results in classcastexceptions at runtime). So what I did was to remove the dependencies from the bundles that use that library, compile them with the library included in the property jars.extra.classpath (in the build.properties of the eclipse project).

然后我添加了

org.osgi.framework.bootdelegation=com.blipsystems.*

在felix配置文件中,并使用以下命令行启动felix容器:

in the felix configuration file and started the felix container with the followin command line:

java -classpath lib/blipnetapi.jar -jar bin/felix.jar

..反过来为blipnetapi.jar库的一个类抛出NoClassDefFoundException:

..which in turns throwed a NoClassDefFoundException for a class of the blipnetapi.jar library:


ERROR: Error starting file:/home/frza/felix/load/BlipnetApiOsgiService_1.0.0.1.jar (org.osgi.framework.BundleException: Activator start error in bundle BlipnetApiOsgiService [30].)
java.lang.NoClassDefFoundError: com/blipsystems/blipnet/api/util/BlipNetSecurityManager
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    at java.lang.Class.getConstructor0(Class.java:2699)
    at java.lang.Class.newInstance0(Class.java:326)
    at java.lang.Class.newInstance(Class.java:308)
    at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:3525)
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:1694)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1621)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1076)
    at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: com.blipsystems.blipnet.api.util.BlipNetSecurityManager
    at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:726)
    at org.apache.felix.framework.ModuleImpl.access$100(ModuleImpl.java:60)
    at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1631)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    ... 11 more

所以我的问题是:我错过了什么吗?我做错了什么?

So my question is: am I missing something? I did something wrong?

推荐答案

问题出在您的命令行中.如果指定-jar选项,则Java将忽略-classpath选项.如果您需要使用-jar指定类路径,则它必须位于您启动的jar的清单中.在这里,我只是将两个jar都放在类路径上,然后手动指定主类(在Felix jar内查看其确切名称).

The problem is in your command line. If you specify the -jar option, java will ignore the -classpath option. If you need to specify a classpath with -jar, it needs to be in the manifest of the jar you start. Here I would simply put both jars on the classpath and manually specify the main class (peek inside the Felix jar for its exact name).

这篇关于如何在osgi中配置系统范围的软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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