Hi ppl,
Would someone who understand setContextClassLoader help me shine some
light at this mistery. I' ve read all the material I could find about
this before I posted this email. I've looked specifically into:
ClassLoader parent delegation model
verification of symbolic references - dynamic linking(4th pass)
Trying to change ClassLoader for the thread, which loads classes from
specific place, i.e classical example. I've overloaded findClass method
in my classloader and expect it to kick in after all parents got their
turn unsuccesfully looking for classes. Here is the simple code snippet
from main:
ClassLoader cl =
Thread.currentThread().getContextClassLoader();
System.out.println("created classloader " + cl);
DbcClassLoader dbccl = new DbcClassLoader(cl);
System.out.println("created classloader " + dbccl);
Thread.currentThread().setContextClassLoader(dbccl);
System.out.println("set the classloader, now it is "
+Thread.currentThread().getContextClassLoader());
ArrayClub club = new ArrayClub(3);
System.out.println("Array loaded by " +
club.getClass().getClassLoader());
club.addMember(new Person());
System.out.println("out now");
And the output is:
[Loaded java.lang.IllegalStateException from /usr/local/jdk1.3/jre/lib/rt.jar]
created classloader com.dreambean.codegen.DbcClassLoader@7b7072
set the classloader, now it is com.dreambean.codegen.DbcClassLoader@7b7072
Exception in thread "main" java.lang.NoClassDefFoundError: dbc/test/ArrayClub
at DBCTest.main(DBCTest.java:17)
[Loaded java.lang.Shutdown$Lock from /usr/local/jdk1.3/jre/lib/rt.jar]
I've added debug statements into findclass method of my classloader but it
is never called.My classloader knows where to find ArrayClub !!! but it is
never given turn.
Sorry for the jboss unrelated post.
Thanks,
Vladimir