7 Replies Latest reply on Jan 28, 2005 4:45 AM by Dawie Malan

    Hibernate MBean in .HAR files behaves incorrectly

    Mark Newbie

      According to the documentation at http://www.jboss.org/wiki/Wiki.jsp?page=JBossHibernate
      the mapping files are picked up automatically.

      Notice that there is no option to specify the mapping documents to load. That is because the Hibernate MBean is meant to work in conjuction with the HAR Deployer component and gets this information from there.


      However, when I make a .HAR file with the following META-INF/hibernate-service.xml file:

      <server>
      <mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory, name=HibernateFactory">
      
       <depends>jboss.jca:service=HARDeployer</depends>
       <depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends>
       <!-- Make it deploy ONLY after DataSource had been started -->
      
       <attribute name="JndiName">java:/HibernateFactory</attribute>
       <attribute name="Datasource">java:/MySqlDS</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="ShowSql">true</attribute>
       <attribute name="UserTransactionName">UserTransaction</attribute>
      </mbean>
      </server>


      and I add my POJO and hbm.xml file to the .HAR file it doesn't want to map my class.

      When I add the following line however (I put it before the JndiName attribute):

      <attribute name="MapResources">saen/core/common/Currency.hbm.xml</attribute>


      Then everything is fine. This would not be so bad by itself. The problem is when I want to deploy more than one .HAR file I get an error upon deployment of the second one informing me the MBean is already defined.

      So how do I go about deploying multiple .HAR files?

      I could see it work if I configure the HibernateService MBean once and then deploy several .HAR files without including the hibernate-service.xml in each one, just the POJOs and mapping documents. That relies on the HAR-deployer loading the mapping documents automatically for me, as is stated in the documentation. The fact that it doesn't do this breaks my deployment strategy.

      I've been strugling with this over a long period of time. Occasionally I have a little time to see if I can solve this problem. Mailings here have gone unanswered so far. We've come to the point where Hibernate is going to be more important to us than JBoss, so if it can't do this we may have to choose another solution for JBoss, or remove it altogether.

      So basically this is a last call for help before we consider ditching JBoss :-{