Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cglib/asm NoClassDefFoundError

4 views
Skip to first unread message

deacent

unread,
Mar 10, 2008, 1:25:27 PM3/10/08
to
I'm having trouble running the cglib sample KeySample
http://cglib.sourceforge.net/xref/samples/KeySample.html. It compiles
fine, but when I try to run it, I get:

Exception in thread "main" java.lang.NoClassDefFoundError: org/
objectweb/asm/Type
at net.sf.cglib.core.TypeUtils.parseType(TypeUtils.java:180)
at net.sf.cglib.core.KeyFactory.<clinit>(KeyFactory.java:66)
at Test.main(Test.java:8)

To ensure asm.jar is definitely in the classpath, I'm running it as:

java -classpath .;$JAVA_HOME/lib;$CGLIB_LIB/cglib-2.1_3.jar;$CGLIB_LIB/
asm.jar;$CGLIB_LIB/aspectwerkz-core-0.10.RC1.jar;$CGLIB_LIB/ant.jar;
$CGLIB_LIB/asm-attrs.jar;$CGLIB_LIB/asm-util.jar;$CGLIB_LIB/jarjar.jar;
$CGLIB_LIB/junit.jar KeySample

The call in net.sf.cglib.core.KeyFactory which is triggering this is:

private static final Type KEY_FACTORY =
TypeUtils.parseType("net.sf.cglib.core.KeyFactory");

The call at net.sf.cglib.core.TypeUtils.parseType is:

public static Type parseType(String s) {
return Type.getType(map(s));
}

map is a private method which effectively transforms the input into
"L"+s.replace('.', '/'))+";" (i.e. "Lnet/sf/cglib/core/KeyFactory;").
I've traced through this with Eclipse, so I'm absolutely certain that
this is what's being passed to Type.getType. Based on the exception
and my trace, I don't think it's getting as far as calling
Type.getType, though.

If I add the lines:

org.objectweb.asm.Type t = Type.getType("Lnet/sf/cglib/core/
KeyFactory;");
System.out.println(t.getClassName());

to the sample code, those lines execute properly (i.e. it prints
"net.sf.cglib.core.KeyFactory"), but then it throws the exception
above.

The fun part is that I get the same result if I re-compile the
original sample code and run with the no-dependency version of cglib:

java -classpath .:$JAVA_HOME/lib:$CGLIB_LIB/cglib-nodep-2.1_3.jar
KeySample

I suspect that there's something truly screwed up with my environment,
but I haven't seen any other overt misbehavior like this. Any ideas?

Roedy Green

unread,
Mar 12, 2008, 5:52:14 AM3/12/08
to
On Mon, 10 Mar 2008 10:25:27 -0700 (PDT), deacent
<je...@mavericklabel.com> wrote, quoted or indirectly quoted someone
who said :

>NoClassDefFoundError

this is probably the hardest of all exceptions to track down since it
has so many causes.

see
http://mindprod.com/jgloss/runerrormessages.html#NOCLASSDEFFOUNDERROR
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

0 new messages