尽管 OSGi 包存在,但出现 NoClassDefFoundError
当尝试在 Eclipse Equinox 上运行 grails 应用程序时,出现运行时错误。
java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:580)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:550)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:481)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass_LockClassLoader(ClasspathManager.java:469)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:449)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:393)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:469)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
问题是我的包正在导入以下包 com.springsource.org.apache.commons.collections;版本=“3.2.1” 在搜索 spring EBR 时,我发现该包包含所需的类。
我使用监视工具来确保捆绑包正在运行。
可能是什么问题?
问候 ?
I get a run time error when trying to run a grails application on Eclipse Equinox.
java.lang.NoClassDefFoundError: org/apache/commons/collections/Transformer
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:580)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:550)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:481)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass_LockClassLoader(ClasspathManager.java:469)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:449)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:393)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:469)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
The problem is that my bundle is importing the following package com.springsource.org.apache.commons.collections; version="3.2.1"
When searching spring EBR I find that the bundle contains the required Class.
I used monitor tool to make sure that the bundle is running.
What can be the problem ?
Regards ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据您所写的内容,您正在导入包 com.springsource.org.apache.commons.collections,但这是 Spring 构建的 OSGi 版本的 org.apache.commons.collections jar 文件。它是一个捆绑包,而不是一个包。
您的捆绑包必须导入 org.apache.commons.collections,它是由 com.springsource.org.apache.commons.collections 捆绑包提供的。假设您已经向运行时提供 Spring 包,您只需修复 import 语句即可。
在现有清单中,将(在“导入包”部分下)更改
为:
Based on what you wrote, you are importing the package com.springsource.org.apache.commons.collections, but that is a a Spring built OSGi version of the org.apache.commons.collections jar file. It is a bundle, not a package.
Your bundle would have to import org.apache.commons.collections, which is provided by the com.springsource.org.apache.commons.collections bundle. Assuming you are already supplying the Spring bundle to the runtime, you simply need to fix the import statement.
In your existing manifest, change (under your Import-Package section):
to
您的捆绑包无法导入包
com.springsource.org.apache.commons.collections
,因为没有这样的包。您的意思可能是您已经安装了具有该名称的捆绑包。该错误意味着您的捆绑包未导入包
org.apache.commons.collections
,即它必须出现在捆绑包的Import-Package
语句中的某个位置。Your bundle cannot import the package
com.springsource.org.apache.commons.collections
because there is no such package. What you probably mean is that you have installed the bundle with that name.The error means that your bundle does not import the package
org.apache.commons.collections
, i.e. it must appear somewhere in theImport-Package
statement of your bundle.将 commons-collections jar 文件添加到构建路径将解决此问题。
Adding commons-collections jar file to your build path will solve this issue.