In my application, which runs in JBoss 3.2.1, I have a SAR that contains the hbm.xmls + the jboss-service.xml, generated by Hibernate XDoclet 1.2beta4. Here is the generated jboss-service.xml.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server>
<!-- Generated file - Do not edit! -->
<server>
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=Hibernate">
<depends>jboss.jca:service=RARDeployer</depends>
<attribute name="MapResources">com/galenworks/procedurelink/hibernate/UserDistribution.hbm.xml, blah blah blah</attribute>
<attribute name="JndiName">java:/GWHibernateFactory</attribute>
<attribute name="Datasource">java:/galenworksDS</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.PostgreSQLDialect</attribute>
<attribute name="UseOuterJoin">true</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="UserTransactionName">UserTransaction</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
</mbean>
</server>
The core Hibernate jars are in server/default/lib, as per the documentation on Hibernate.org.
My application is happy under 2.1 beta 6. Upgrading to 2.1 rc1, I am seeing the following problem.
As before, the Hibernate SAR deploys happily as the server is coming up, but there is this suspicious section in the log file:
Code:
[net.sf.hibernate.cfg.SettingsFactory] cache provider: net.sf.ehcache.hibernate.Provider
[net.sf.hibernate.jmx.HibernateServiceMBean] Could not build SessionFactory using the MBean classpath - will try again using client classpath: could not instantiate CacheProvider: net.sf.ehcache.hibernate.Provider
The first time I try to do:
Code:
Context jndiContext = new InitialContext();
SessionFactory factory =
(SessionFactory) jndiContext.lookup(hibernateFactory);
session = factory.openSession();
...Hibernate initializes again and blows up with:
Code:
net.sf.hibernate.LazyInitializationException: Hibernate lazy instantiation problem
at net.sf.hibernate.jmx.SessionFactoryStub.getImpl(SessionFactoryStub.java:77)
at net.sf.hibernate.jmx.SessionFactoryStub.openSession(SessionFactoryStub.java:62)
...snip....
Caused by: net.sf.hibernate.HibernateException: could not instantiate CacheProvider: net.sf.ehcache.hibernate.Provider
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:115)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1072)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:718)
at net.sf.hibernate.jmx.HibernateService.buildSessionFactory(HibernateService.java:162)
at net.sf.hibernate.jmx.SessionFactoryStub.getImpl(SessionFactoryStub.java:74)
... 25 more
Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: net.sf.ehcache.hibernate.Provider
at org.jboss.mx.loading.LoadMgr.beginLoadTask(LoadMgr.java:161)
at org.jboss.mx.loading.UnifiedClassLoader3.loadClass(UnifiedClassLoader3.java:175)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:75)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:112)
... 29 more
From this, I assumed that ehcache (not JCS, which I know is deprecated) is now the default caching mechanism. Everything worked when I included the ehcache.jar.
Can someone confirm this? Can the documentation be made clearer on this area (ie. lib/libs-readme.txt)?
Thanks!
Sherman