[jboss-user] [EJB/JBoss] - Thread.getContextClassLoader() and scoped classloading

be326814 do-not-reply at jboss.com
Fri Aug 31 05:02:38 EDT 2007


I found an issue with the proposed way to access the current classloader.  The wiki and this forums always tell to use:
Thread.currentThread().getContextClassLoader().loadClass("package.className");
For most cases that is the right way to do it, exept in the following senario.

2 Distinct EARs, both with scoped classloading.  A single jboss instance where jndi is configured with call-by-value too true.  When EAR A does a call to EAR B and in that call EAR B tries to dyamicly create a class using the above code, then the wrong class loader is used (the classloader of EAR A is used).  The reason is simple, different EARs on the same instance will not start a new thread when calling each other (for performance reasons).

The above senario is not as special as it seems.  Somethimes different version of the same EAR must run simultaniously on the same server, and then scoped classloading is very usefull.  2 Parts of an application (read EARs) may run on different servers in production but on the same server in test/staging.


My question is, is there a solution to this problem? Maybe something that already exists or that can be added?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079881#4079881

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079881



More information about the jboss-user mailing list