Java Classloader Problem


General J2EE: Java Classloader Problem

  1. Java Classloader Problem (3 messages)

    I wrote a custom classloader to dynamically load classes
    present in a certain directory( *not* present in the CLASSPATH). ( So that I need not restart AppServer, everytime I add a new class)

    I am able to succefully load a class( say A.class), *BUT* when that class(A.class) uses other classes(B.class) present in that directory, then it is reporting classnotfound exception.

    I believe A.class is delegating the the work of finding B.class to the parent classloader instead of the "custom classloader".

    Is there any method, by which you can force a class to use the custom classloader or anything like that. Can anyone pls advise/suggest me what whould be a right approach


    Threaded Messages (3)

  2. Java Classloader Problem[ Go to top ]

    In the Class Object there is a method.

    public static Class forName(String name,
                                boolean initialize,
                                ClassLoader loader)
                         throws ClassNotFoundException
  3. Java Classloader Problem[ Go to top ]

    Try to load B.class using the same classloader since
    the same class loaded by different classloader is treated
    as two different classes.
  4. Java Classloader Problem[ Go to top ]

    I have no control over A.class and B.class. A.class uses B.class.