This content has been marked as final.
Show 5 replies
-
1. Re: How Can I dynimicly load a Class in Session Bean (Statel
sportsbaby1980 Jan 10, 2005 11:27 PM (in response to sportsbaby1980)The appliction Server is Jboss4.0.
JDK is 1.42_05.
I need your help -
2. Re: How Can I dynimicly load a Class in Session Bean (Statel
sportsbaby1980 Jan 11, 2005 1:05 AM (in response to sportsbaby1980)Maybe I should read jboss4.0 src?
-
3. Re: How Can I dynimicly load a Class in Session Bean (Statel
frito Jan 11, 2005 3:50 AM (in response to sportsbaby1980)You must not do a Class.forName, instead use
Thread.currentThread().getContextClassLoader().getResourceAsStream() Thread.currentThread().getContextClassLoader().loadClass()
If you still encounter problems read the wiki for classloader configuration (http://www.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration) and check your assembly. There are, with the utmost probability, resources missing. -
4. Re: How Can I dynimicly load a Class in Session Bean (Statel
fredatwork Jan 11, 2005 11:37 AM (in response to sportsbaby1980)You definitely have to load a class as Frito told you :
Thread.currentThread().getContextClassLoader().loadClass()
But also, I would consider migrating immediately consider to JBoss 4.0.1.
I had plenty of problems with JBoss 4.0.0 loading classes of mine dynamically and more generally with the JBoss class loader (e.g. with JBossCache) , expecially for classes included in an EJB jar file, that in turns is itself contained inside an EAR file (like you do). I posted several subjects on this. I received the same exception as you did (class not found !).
I had test cases working with JBoss 4.0.0 RC2 but not with JBoss 4.0.0. When I migrated to JBoss 4.0.1, evrything went allright as with prior versions to 4.0.0.
I believed JBoss 4.0.0 class loader was somehat buggy. But JBoss tech leaders said JBoss 4.0.1 only changed some xml config of the class loader (they refered to release notes).
Fred -
5. Re: How Can I dynimicly load a Class in Session Bean (Statel
keros Jan 17, 2005 1:25 PM (in response to sportsbaby1980)I've been having classloader problems as well with 3.2.3 (I've tried w/ 3.2.6 as well). I did the
Thread.currentThread().getContextClassLoader().getResourceAsStream() Thread.currentThread().getContextClassLoader().loadClass()
which works great. I now get my class loaded just fine. However, I now get a NoClassDefFoundError in the method that calls the method with the above code in it.
I know the code works (not including the above) outside of jboss. FYI, the RTE is "java.lang.NoClassDefFoundError: javax/ejb/EJBObject". I can supply a more detailed code example if requested. It just may take some time to cut out the right code.