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 ?
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):
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. 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 the Import-Package
statement of your bundle.
Adding commons-collections jar file to your build path will solve this issue.
精彩评论