1 Reply Latest reply on Aug 31, 2007 7:22 AM by Bryan Brouckaert

    Thread.getContextClassLoader() and scoped classloading

    Bryan Brouckaert Newbie

      I found an issue with the proposed way to access the current classloader. The wiki and this forums always tell to use:


      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?