-
1. Re: Loading classes via reflection and NoClassDefFoundError
triathlon98 Apr 13, 2004 11:38 AM (in response to dlamotta)How are you loading your classes?
Are you using Class.forName ?
If you are, then that may be the cause of your problems. In JBoss you should not use the system classloader, as that one does not handle the hot deployment, the UnifiedClassloaders et al. You should use
Thread.currentThread().getContextClassLoader().loadClass()
Joachim -
2. Re: Loading classes via reflection and NoClassDefFoundError
dlamotta Apr 13, 2004 11:51 AM (in response to dlamotta)No, I am not using Class.forName. I am using ClassLoader.defineName. I believe the problem stems from the ClassLoader. Although it does not solve my original problem, using Thread.currentThread().getContextClassLoader().loadClass() alleviates the problem a little bit. For this, I have to put colored apples in a Jar and then drop that Jar in the lib directory of my server.
Again, if I stick to my original implementation (i.e., reading class files from the filesystem, populating byte arrays, and then calling defineClass()) I am still hosed.
Thanks for your suggestion, though. -
3. Re: Loading classes via reflection and NoClassDefFoundError
nickman Apr 13, 2004 12:34 PM (in response to dlamotta)David;
You need to delegate the class loading to the cloass loader for the deployment that FruitHarvester was loaded by. The NoClassDefFoundError error is caused by same classes being loaded by two seperate class loaders.
Make your custom class loader delegate to:fruitHarvester.getClass().getClassLoader()
//Nicholas