我在尝试运行捆绑激活器时遇到此异常:
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
)是一个系统包。即。
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
属性就是这样做的。这是对的吗?