cglib/asm NoClassDefFoundError

D

deacent

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top