-->
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.  [ 3 posts ] 
Author Message
 Post subject: Multiple Hibernate MBean deployment on JBoss?
PostPosted: Thu Sep 23, 2004 12:19 am 
Newbie

Joined: Wed Sep 22, 2004 11:59 pm
Posts: 2
Location: norcal
I've been using hibernate 2.1 with mysql 4.0.18 inside of JBoss 3.2.3 for sometime with good results. I have the hibernate files (mapping and bean files) deployed as an MBean in a separate Service Archive (SAR) as described on the Hibernate web site(www.hibernate.org/66.html). The hibernate library and related jars are deployed in JBOSS_HOME/server/default/lib. This MBean is accessed by several webapps deployed in the same JBoss instance.

My problem has arisen from my attempts to deploy a second MBean to reference a separate database. The first approach I used was to simply deploy a second MBean SAR, after changing the requisite JNDI name. The MBeans deployed correctly and the SessionOBjectFactories were bound to the proper JNDI locations. Subsequently all attempts to reference any of the existing tables in the second MBean(as in the MBean that loaded second) resulted in the error message that "No persistent classes found for ...". I surmised that this might be due to the vagaries of the JBoss UnifiedClassloader, so I added the classloader tag <loader-repository> ... to the jboss-service.xml. This was no help and neither were my other attempts to package the MBean in a more self contained manner. I tried to place the MBean SAR inside of a separate EAR to provide further classloader containment, but to no avail.

I also tried to place the MBean SAR inside of each webapp EAR. This worked upto the point where I needed to have multiple copies of the MBean which caused JNDI conflicts. While it's possible that I could create identical copies of the MBeans with slightly different JNDI names for each client webapp to deploy, this seems the wrong way to go.

My question is how are folks handling deployment of mulitple hibernate MBeans. In my particular case, I have many webapps and only 2 separate databases. Is it possible to deploy only the expected minimum 2 MBeans to service all of my webapps? This would seem to be the logical approach and perhaps I've just missed something in my implementation.


-



Hibernate version:2.1

Mapping documents: for first MBean
<server>
<loader-repository>hibernate.ols:loader=hibernate-ols.sar</loader-repository>

<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory,
name=HibernateFactory">
<depends>jboss.jca:service=RARDeployer</depends>
<depends>jboss.jca:service=LocalTxCM,name=olsDB</depends>
<!-- Make it deploy ONLY after DataSource had been started -->
<attribute name="MapResources">map/Company.hbm.xml,map/Language.hbm.xml,map/Manifest.hbm.xml,
map/Manifestexcludeservice.hbm.xml,map/Manifestservice.hbm.xml,
map/Oem.hbm.xml,map/Product.hbm.xml,map/Service.hbm.xml,
map/Servicerank.hbm.xml,map/User.hbm.xml,map/Notification.hbm.xml,
map/Servicetracking.hbm.xml,map/Companylanguage.hbm.xml,
map/Country.hbm.xml,map/Media.hbm.xml</attribute>
<attribute name="JndiName">java:/HibernateFactory</attribute>
<attribute name="Datasource">java:/olsDB</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.MySQLDialect</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="UseOuterJoin">false</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="UserTransactionName">UserTransaction</attribute>
<attribute name="CacheProvider">net.sf.ehcache.hibernate.Provider</attribute>
<attribute name="UseQueryCache">true</attribute>
</mbean>


</server>

Mapping documents: for second MBean:
<server>

<loader-repository>hibernate.ols.email:loader=hibernate-ols-email.sar</loader-repository>

<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactoryEmail,
name=HibernateFactoryEmail">
<depends>jboss.jca:service=RARDeployer</depends>
<depends>jboss.jca:service=LocalTxCM,name=olsDBemail</depends>
<!-- Make it deploy ONLY after DataSource had been started -->
<attribute name="MapResources">map/EmailMessage.hbm.xml,map/ForwardBounce.hbm.xml,
map/SenderAccount.hbm.xml</attribute>
<attribute name="JndiName">java:/HibernateFactoryEmail</attribute>
<attribute name="Datasource">java:/olsDBemail</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.MySQLDialect</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="UseOuterJoin">false</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="UserTransactionName">UserTransaction</attribute>
<attribute name="CacheProvider">net.sf.ehcache.hibernate.Provider</attribute>
<attribute name="UseQueryCache">true</attribute>
</mbean>
</server>



Name and version of the database you are using:Mysql 4.0.18

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 23, 2004 12:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Are you able to deploy each of the two mbeans seperately?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 23, 2004 9:41 am 
Newbie

Joined: Wed Sep 22, 2004 11:59 pm
Posts: 2
Location: norcal
I failed to mention that my current problem when deploying 2 MBeans is that I get back a null session from my JNDI lookup for the SessionFactory. Both SessionFactories are bound in to JNDI as verified via the JMX console.

I'm suspicious of my current changes to deploy an MBean in a SAR inside of an EAR. While it appears to load and bind correctly, I only get null sessions from my JNDI lookup.

I tried deploying a single MBean SAR inside an EAR and I have the same null session problem. Any examples of how deploy multiple MBeans either as SARs or inside EARs?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.