title: Classloader issue in JBoss AS 6 with EJBs and WARs deployed side-by-side
body: <p>I've found a pretty intricate problem while working on a project with multiple EE deployables. The problem seems to be a confluence of the EJB3.1 TimerService's Hibernate dependencies and insufficient classloader isolation.</p>
  
  <p>Starting with a stock AS 6 CR1 build, I deploy a WAR. This WAR contains Hibernate jars.</p>
  
  <p>Then, I deploy an EJB (technically an MDB) in a JAR. When I do so, JBoss then starts up the TimerService, in order to provide full EJB3.1 support. The TimerService depends on Hibernate. JBoss then goes on strike, because the classloader detects an already loaded version of Hibernate.</p>
  
  <p>I've even tried packaging each of these up into a separate EAR and deploying them. No dice. Something about the way the TimerService is being loaded seems to totally ignore classloading isolation.</p>
  
  <p>My question is, is there anything I can do about it, short of disabling the TimerService? I was intending to make use of its nifty features later in the project. I honestly don't even know if this is a bug, as the classloader documentation for JBoss seems to have been written by angry Klingons. Still, I hope for a work-around.</p>
  
  <p><strong>EDIT</strong> - In fact, I don't even have a way of disabling the TimerService, as each of my efforts has been thwarted in one way or another. As it stands, I don't see how anyone can deploy Hibernate and EJBs to the same JBoss instance.</p>
  
  <p><strong>EDIT</strong> - I eventually managed to deploy by not including the Hibernate jars in my MDB or WAR, but to rely on JBoss' Hibernate implementation. This is unsatisfying; I'm left with the feeling that there's no isolation between the container and my beans. But at least it's a current version of Hibernate (3.6).</p>