1

尝试运行捆绑激活器时出现此异常:

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) 是系统包。IE

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财产是这样做的。那是对的吗?

4

0 回答 0