简体   繁体   English

NoClassDefFoundError 虽然有 OSGi 包

[英]NoClassDefFoundError although OSGi bundle is there

I get a run time error when trying to run a grails application on Eclipse Equinox.尝试在 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)

The problem is that my bundle is importing the following package com.springsource.org.apache.commons.collections; version="3.2.1"问题是我的包正在导入以下 package com.springsource.org.apache.commons.collections; version="3.2.1" com.springsource.org.apache.commons.collections; version="3.2.1" When searching spring EBR I find that the bundle contains the required Class. com.springsource.org.apache.commons.collections; version="3.2.1"在搜索 spring EBR 时,我发现该捆绑包包含所需的 Class。

I used monitor tool to make sure that the bundle is running.我使用监视工具来确保捆绑包正在运行。

What can be the problem?可能是什么问题?

Regards?问候?

Based on what you wrote, you are importing the package com.springsource.org.apache.commons.collections , but that is aa Spring built OSGi version of the org.apache.commons.collections jar file. Based on what you wrote, you are importing the package com.springsource.org.apache.commons.collections , but that is aa Spring built OSGi version of the org.apache.commons.collections jar file. It is a bundle, not a package.它是一个捆绑包,而不是 package。

Your bundle would have to import org.apache.commons.collections , which is provided by the com.springsource.org.apache.commons.collections bundle. 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.假设您已经将 Spring 捆绑包提供给运行时,您只需修复导入语句。

In your existing manifest, change (under your Import-Package section):在您现有的清单中,更改(在您的 Import-Package 部分下):

com.springsource.org.apache.commons.collections;version="3.2.1"

to

org.apache.commons.collections;version="3.2.1"

Your bundle cannot import the package com.springsource.org.apache.commons.collections because there is no such 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 , ie it must appear somewhere in the Import-Package statement of your bundle.该错误意味着您的包没有导入 package org.apache.commons.collections ,即它必须出现在您的包的Import-Package语句中

Adding commons-collections jar file to your build path will solve this issue.将 commons-collections jar 文件添加到您的构建路径将解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM