Hi Vladimir, You oversaw a minimal linking issue ... In your example, the ArrayClub.class is indeed dynamically linked to your Main.class (the one carrying the code snippet your presented) and hence the normal System classloader is used for resolution. Doing a Class.forName(String) uses the caller`s classloader which is again Main.class/SystemClassLoader and hence would also not help. I�m not sure whether the context classloader is anywhere in the Java libs explicitely triggered for resolution - a scan over the whole java.lang Package gave no evidence. Seems like the context classloader has been introduced a bit later and is yet not fully adopted? In our code, we have hence introduced the code discipline to always do a Thread.currentThread().getContextClassLoader.loadClass(String) or a Class.forName(String,boolean,Thread.currentThread().getContextClassLoader()) to avoid these problems. Hope that helps, CGJ -----Urspr�ngliche Nachricht----- Von: Vladimir A Blagojevic [mailto:[EMAIL PROTECTED]] Gesendet: Samstag, 27. Januar 2001 15:51 An: [EMAIL PROTECTED] Betreff: [jBoss-Dev] Thread.setContextClassLoader() problem 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
