0

我一直在尝试使用 OSGi 包中的 activeMQ,但遇到了一些问题。我现在已经得到了上面的那个,我不确定我需要做什么。通常,当我收到此错误时,仅表示您没有导入所需的包,但我已经在清单文件中添加了 javax.naming 包。

这就是我的清单文件的样子。

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: com.activemq.test
Bundle-SymbolicName: com.activemq.test
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-Activator: com.activemq.test.App
Import-Package: javax.jms,
 javax.naming,
 org.osgi.framework
Require-Bundle: ActiveMQExportTest;bundle-version="1.0.0"

我正在运行他们在其网站上提供的 activeMQ helloworld 应用程序。当我正常运行它时它工作得很好,但是如果你将它包装到一个 osgi 包中它就会开始失败。

编辑:我不知道它是否相关,但Required-Bundle 是包含在插件中的activeMQ-all jar,用于公开我需要的包。

堆栈跟踪。如果你需要别的东西,请告诉我。

[7/30/13 9:14:17:782 CDT] 00000018 LogService-64-com.ibm.ws.org.apache.aries.proxy.1.0.2        E CWWKE0701E: FrameworkEvent ERROR Bundle:com.ibm.ws.org.apache.aries.proxy.1.0.2(id=64) java.lang.ClassFormatError: Unexpected error from weaving hook.
    at org.eclipse.osgi.internal.baseadaptor.weaving.WeavingHookConfigurator.processClass(WeavingHookConfigurator.java:74)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:600)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:568)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:492)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:465)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:464)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:690)
    at java.lang.Class.forNameImpl(Native Method)
    at java.lang.Class.forName(Class.java:219)
    at org.apache.aries.proxy.impl.common.AbstractWovenProxyAdapter.visit(AbstractWovenProxyAdapter.java:228)
    at org.objectweb.asm.ClassVisitor.visit(Unknown Source)
    at org.objectweb.asm.commons.SerialVersionUIDAdder.visit(Unknown Source)
    at org.apache.aries.proxy.impl.weaving.SyntheticSerialVerUIDAdder.visit(SyntheticSerialVerUIDAdder.java:60)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.apache.aries.proxy.impl.weaving.WovenProxyGenerator.getWovenProxy(WovenProxyGenerator.java:54)
    at org.apache.aries.proxy.impl.weaving.ProxyWeavingHook.weave(ProxyWeavingHook.java:87)
    at org.eclipse.osgi.internal.baseadaptor.weaving.WovenClassImpl.call(WovenClassImpl.java:140)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyHookPrivileged(ServiceRegistry.java:1239)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyHooksPrivileged(ServiceRegistry.java:1222)
    at org.eclipse.osgi.internal.baseadaptor.weaving.WovenClassImpl.callHooks(WovenClassImpl.java:182)
    at org.eclipse.osgi.internal.baseadaptor.weaving.WeavingHookConfigurator.processClass(WeavingHookConfigurator.java:68)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:600)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:568)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:492)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:465)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:690)
    at com.ibm.activemq.test.App$HelloWorldProducer.run(App.java:73)
    at java.lang.Thread.run(Thread.java:780)
Caused by: java.lang.NoClassDefFoundError: javax.naming.Referenceable
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:632)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:607)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:568)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:492)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:465)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:464)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:690)
    at java.lang.Class.forNameImpl(Native Method)
    at java.lang.Class.forName(Class.java:219)
    at org.apache.aries.proxy.impl.common.AbstractWovenProxyAdapter.checkInterfacesForSerializability(AbstractWovenProxyAdapter.java:308)
    at org.apache.aries.proxy.impl.common.AbstractWovenProxyAdapter.visit(AbstractWovenProxyAdapter.java:231)
    at org.objectweb.asm.ClassVisitor.visit(Unknown Source)
    at org.objectweb.asm.commons.SerialVersionUIDAdder.visit(Unknown Source)
    at org.apache.aries.proxy.impl.weaving.SyntheticSerialVerUIDAdder.visit(SyntheticSerialVerUIDAdder.java:60)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.apache.aries.proxy.impl.weaving.WovenProxyGenerator.getWovenProxy(WovenProxyGenerator.java:54)
    at org.apache.aries.proxy.impl.weaving.ProxyWeavingHook.weave(ProxyWeavingHook.java:87)
    at org.eclipse.osgi.internal.baseadaptor.weaving.WovenClassImpl.call(WovenClassImpl.java:140)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyHookPrivileged(ServiceRegistry.java:1239)
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyHooksPrivileged(ServiceRegistry.java:1222)
    at org.eclipse.osgi.internal.baseadaptor.weaving.WovenClassImpl.callHooks(WovenClassImpl.java:182)
    at org.eclipse.osgi.internal.baseadaptor.weaving.WeavingHookConfigurator.processClass(WeavingHookConfigurator.java:68)
    ... 40 more
Caused by: java.lang.ClassNotFoundException: javax.naming.Referenceable
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:690)
    at java.lang.ClassLoader.defineClassImpl(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:295)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
    ... 68 more

如果有人有任何建议,我很乐意采纳。谢谢!

4

1 回答 1

0

通常,当您对缺少的类/接口有静态引用时,您会得到NoClassDefFoundError,而检查的异常ClassNotFoundException通常发生在有人调用Class.forName或其变体之一时。

我怀疑该异常甚至不是来自您在上面显示的清单的捆绑包。即,您的依赖项之一可能使用反射来加载依赖于javax.naming.Reference但该捆绑包不导入包的类。

也许如果您发布完整的堆栈跟踪,它可能会对问题有所了解。请使用此信息更新您的问题,如果我看到任何内容,我将更新此答案。

于 2013-07-30T14:53:52.333 回答