-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Hibernate 2.1rc1 problem: JBoss MBean/SAR deployment
PostPosted: Sat Dec 06, 2003 3:07 am 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 9:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
ehcache is now (from rc1) the default second level cache in 2.1 .


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 10:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You should be able to specify a different Cache Provider for your MBean, by using the MBean Code from CVS, where Gavin included this *great*


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 06, 2003 12:51 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
So we have 2 things:

1. The documentation about Hibernate and JBoss is out of date and/or could be made more clear ie. http://www.hibernate.org/66.html and lib/libs-readme.txt. For example, you do not need to put jars needed for Hibernate in the server/default/lib directory - they can go in the SAR or EAR, at least with Hibernate 2.1 and JBoss 3.2.X.


I'll add some comments on 66.html about what appears to work.


2. The latest HibernateService and HibernateServiceMBean in CVS need to be included in later release candidates, as I see you are planning (JIRA issue HB-509). I see they have attributes for the cache provider (amongst other things).

That way we can do:

<attribute name="CacheProvider">net.sf.ehcache.hibernate.Provider</attribute>

in the MBean descriptor.

Until Hibernate XDoclet catches up, XDoclet users can use a jboss-service-custom.xdt merge point to include the new attributes into the generated jboss-service.xml for the SAR.

Again, I'll add some comments on this in 66.html.




Cheers,


Sherman


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.