I want to use hibernate 3.0.2 in my ear under JBoss 4.0.3SP1 without touching  
the default install of hibernate in the server/default/lib directory (I need to 
play nice with any other apps that are expecting that version of hibernate).  I 
also want to use the har service (i.e. the org.jboss.hibernate.jmx.Hibernate 
MBean).  I am using an ear with isolated class loading.  The ear contains a 
.deployer which loads up all the third party jars I use, including the newer 
hibernate3.jar.

If I use the HibernateMBean, it will instantiate the 
org.hibernate.cfg.Configuration using classes from the hibernate3.jar in 
server/default/lib, thus causing the session factory and everything else to 
come from there.

The only solution I have found is to put a copy of jboss-hibernate.jar into the 
.deployer in my ear.  The HibernateMBean is then loaded with my ear's class 
loader, and the call to 

  |       Configuration cfg = new Configuration();
  | 

in buildSessionFactory() also uses that class loader and properly pulls the 
newer hibernate classes from the hibernate3.jar local to my app.

Is there any other way to do this that I am missing?  It seems like 
HibernateMBean should either have an optional ConfigurationFactory attribute 
which can return a new Configuration object (using the right class loader) or 
possibly it should do something like:


  | ClassLoader cl = Thread.currentThread().getContextClassLoader();
  | Class cfgClass = cl.findClass("org.hibernate.cfg.Configuration");
  | Configuration cfg = cfgClass.newInstance();
  | 

Pardon me if that wouldn't work.  My knowledge of ClassLoaders has grown by 
about 1000% in the past two days while pounding my head on this, but it is 
still very limited.


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

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


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to