如何在osgi中配置系统范围的包?

发布于 2024-08-06 09:04:07 字数 2004 浏览 3 评论 0原文

我需要为某些捆绑包提供一个库。该库使用 RMI,因此它需要(至少据我所知)使用系统类加载器才能工作(我尝试“osgi-fy”该库,这会在运行时导致类转换异常)。所以我所做的就是从使用该库的包中删除依赖项,使用属性 jars.extra.classpath(在 eclipse 项目的 build.properties 中)中包含的库来编译它们。

然后我添加

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

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

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

..这又为 blipnetapi.jar 库的类引发了 NoClassDefFoundException:

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

所以我的问题是:我是否遗漏了某些内容?我做错了什么吗?

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).

Then I added

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

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

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

..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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缘字诀 2024-08-13 09:04:07

问题出在你的命令行上。如果指定 -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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文