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:

      <mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory, name=HibernateFactory">
       <!-- 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>

      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 :-{

        • 1. Re: Hibernate MBean in .HAR files behaves incorrectly
          Mark Newbie

          Just in case it's of any importance: I used JBoss 4.0.1 with the Hibernate libraries that were included.

          • 2. Re: Hibernate MBean in .HAR files behaves incorrectly
            Dawie Malan Newbie

            Change code="net.sf.hibernate.jmx.HibernateService" to code="net.sf.hibernate.jmx.Hibernate", and change the name to something else, e.g. name="your.app:service=Hibernate"

            • 3. Re: Hibernate MBean in .HAR files behaves incorrectly
              Mark Newbie

              I tried your suggestion, however then I get the following messages:

              17:03:32,671 INFO [MainDeployer] Deployment of package: file:/C:/jboss-3.0.8/server/default/deploy/011_saen_core_hibernate.har is waiting for an appropriate deployer.

              and a little later:

              17:03:35,609 ERROR [URLDeploymentScanner] MBeanException: Exception in MBean operation 'checkIncompleteDeployments()'
              Cause: Incomplete Deployment listing:
              Packages waiting for a deployer:
              [org.jboss.deployment.DeploymentInfo@31960b94 { url=file:/C:/jboss-3.0.8/server/
              default/deploy/011_saen_core_hibernate.har }
              deployer: null
              status: null
              state: INIT_WAITING_DEPLOYER
              watch: file:/C:/jboss-3.0.8/server/default/deploy/011_saen_core_hibernate.har
              lastDeployed: 1106841812671
              lastModified: 1106841812671

              Am I still missing some important detail?

              • 4. Re: Hibernate MBean in .HAR files behaves incorrectly
                Dawie Malan Newbie

                JBoss 3.0 does not have a har deployer, upgrade to the latest version (4.0.1).

                • 5. Re: Hibernate MBean in .HAR files behaves incorrectly
                  Mark Newbie

                  I see. Indeed I had switched back to JBoss 3 in the meantime. I'll try your suggestion with JBoss 4, thanks for your help.

                  • 6. Re: Hibernate MBean in .HAR files behaves incorrectly
                    Mark Newbie

                    Today I tried it with JBoss 4.0 and I got it to work. Many thanks for the solution.

                    One thing though, your suggestion of changing


                    gave me an error saying it couldn't find the ClassLoader for net.sf.hibernate.jmx.Hibernate. So I changed it back to its original, and then it worked.

                    So in the end it turned out all I needed to do was change


                    I suppose I could have figured this out myself if I had known more about the workings of the hibernate-service.xml file. Or maybe it's general JMX knowledge? I tried to look for some more documentation on this, but all I can find are example files that are exactly the same as mine. If anyone can give me a pointer where I can learn more about hibernate-service.xml in particular or JMX in JBoss in general I would be very much obliged.

                    • 7. Re: Hibernate MBean in .HAR files behaves incorrectly
                      Dawie Malan Newbie

                      Sorry, I did not check the package, I meant: