Hi fellow ranchers Am trying to implement a Custom Class Loader into my Weblogic App for enabling hot deployment of certain classes. In that, as suggested by various documentation that I have read, I have overridden the findClass() method of the ClassLoader class to 'find' my class. The idea is to let loadClass() method of the ClassLoader class call my customClassLoader's findClass(). But, from the output I am getting, I don't see my class loader's findClass() method being invoked at all. From the API, this is how loadClass() method works... 1) Calls findLoadedClass(). If class is found then returns the class 2) Calls parent's loadClass() method... until the system Class Loader's loadClass() is called or the class is loaded, whichever comes first. 3) Invokes findClass() method. I understand for my code to work as intended, step 3) should occur on my Class Loader's findClass(). However, I dont see it happening. This leads me to believe that probably the class I am trying to load is already being found in step 1) or 2). Can someone explain whats happening? and why my findClass() is not being invoked?
Hi, Okay! I got over that hump... and got stuck on another. What was happening was ... the JVM classloader was probably finding the said class already loaded and hence was not calling my findClass(). So, I changed it to point to another file ... e.g. instead of xxx.class, I gave it xxx.ini Once that was done, I again (inside the code) pointed it back to xxx.class & that invoked my findClass(). The findClass() proceeded as expected & found the class that I wanted loaded. But, for some reason, it still did not invoke the *new* class file... but I still see the result as if the *old* xxx.class is being invoked. Any ideas why the new one is not being loaded inside the JVM???
I'm not sure I understand, but A ClassLoader will only load a Class once. After it has been loaded it is cached in that ClassLoader forever. I highlighted that part, since you can re-load Classes if they change by throwing away the ClassLoader that loaded them and starting a new one. I hope that was your question. Dave
Joined: Aug 01, 2001
I'm not sure I understand, but A ClassLoader will only load a Class once. After it has been loaded it is cached in that ClassLoader forever. I highlighted that part, since you can re-load Classes if they change by throwing away the ClassLoader that loaded them and starting a new one. -------------------------------------------------------------------------- Yes, I do undestand that. I do have a new Class Loader which I invoke from a client by sending a JMS message. While calling the new Class Loader, I pass it the class that I want reloaded. I see the new class loader being instantiated, the overridden findClass() of the new Class Loader being called, the findClass() finds my new class & returns a Class obj. after a call to defineClass(). All this is happening. But, when I run my test case, I still get the same results as if the old version of the Class file I was trying to load is present in the JVM, not the new one. I hope I have been clear this time. thx.