OSGI系统包上的LinkageError

OSGI系统包上的LinkageError,osgi,apache-felix,Osgi,Apache Felix,我在尝试运行捆绑激活器时遇到此异常: java.lang.LinkageError: loader constraint violation: when resolving method "com.openaf.osgi.OSGIUtils$.mapToDictionary(Lscala/collection/immutable/Map;)Ljava/util/Dictionary;" the class loader (instance of org/apache/felix/framewor

我在尝试运行捆绑激活器时遇到此异常:

java.lang.LinkageError: loader constraint violation: when resolving
method "com.openaf.osgi.OSGIUtils$.mapToDictionary(Lscala/collection/immutable/Map;)Ljava/util/Dictionary;"
the class loader (instance of
org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) of
the current class, com/openaf/test/TestBundleActivator, and the class
loader (instance of sun/misc/Launcher$AppClassLoader) for resolved
class, com/openaf/osgi/OSGIUtils$, have different Class objects for
the type a/util/Dictionary; used in the signature
    at com.openaf.test.TestBundleActivator.start(TestBundleActivator.scala:11)
看起来
java.util.Dictionary
是由两个不同的类加载器加载的,但我不知道为什么。导致问题的类(
com.openaf.osgi.OSGIUtils
)是一个系统包。i、 e

hm.put("org.osgi.framework.system.packages.extra", "sun.misc, com.openaf.osgi")
这是
TestBundleActivator
所在捆绑包的清单:

Manifest-Version: 1
Bnd-LastModified: 1345098244802
Bundle-Activator: com.openaf.test.TestBundleActivator
Bundle-ManifestVersion: 2
Bundle-Name: test.impl
Bundle-SymbolicName: test.impl
Bundle-Version: 0
Created-By: 1.7.0_04 (Oracle Corporation)
Export-Package: com.openaf.test;uses:="scala.collection,scala.collection
 .immutable,com.openaf.test.api,scala.collection.mutable,scala.reflect,o
 rg.osgi.framework,com.openaf.osgi,scala.runtime,scala,com.openaf.utils"
 ;version="0.0.0"
Import-Package: com.openaf.osgi,com.openaf.test.api,com.openaf.utils,org
 .osgi.framework,scala,scala.collection,scala.collection.immutable,scala
 .collection.mutable,scala.reflect,scala.runtime
Tool: Bnd-1.44.0
有人知道我做错了什么吗?我只是假设,因为在系统包中,它应该由基本类加载器加载。看来情况并非如此

谢谢,尼克

编辑-
我应该说我想做什么。当felix应用程序启动时,我在类路径上有一个包,我希望它对所有捆绑包都可用。我认为
org.osgi.framework.system.packages.extra
属性就是实现这一点的方法。正确吗?

这是在第一次激活时,还是在停止并重新启动后?更新之后?另外,我认为您应该解析系统包并“正确”打包com.openaf.osgi包。这很可能是这个问题的原因。此外,错误消息显示的是“a.util.Dictionary”,而不是“java.util.Dictionary”,但假设这是一个复制/粘贴错误?它发生在第一次激活(无缓存)或停止并重新启动(更新后我没有尝试过)之后。我每次都会遇到同样的异常。这不是一个复制粘贴错误,这是我得到的完全例外。我很乐意妥善包装,请详细说明。我真正想要的是,每个包都可以使用这个包。我认为最好的方法是将其添加到系统包中,但我可能错了,请让我知道。好的,如果有一个名为a.util的包,您需要找出为什么有两个导出。它们必须在您添加的捆绑包或第三方捆绑包中。。。使用Gogo()'which'命令列出类的加载位置,例如“which[bundle id]a.util.Dictionary”插入您的bundle id(您可以使用'lb'找到),关于打包,无需将该包添加到系统包中。只需将其放入一个包中并导出包,然后为需要使用它的所有包导入包。这就是模块化编程的要点!如果这行得通,我建议你回答你自己的问题。