13 Replies Latest reply on Apr 20, 2005 7:58 AM by Dina Grover

    using hibernate in jboss-4.0.0

    Emily Newbie

      Trying to get hibernate working with jboss4.0.0. I've got a hibernate .har which is pretty much empty except for the META-INF/hibernate-service.xml file

      
      <server>
       <mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=Hibernate">
       <depends>jboss.jca:service=LocalTxCM,name=TxOracleDS</depends>
       <attribute name="MapResources">
       <!--some files-->
       </attribute>
       <attribute name="JndiName">java:/HibernateFactory</attribute>
       <attribute name="Datasource">java:/TxOracleDS</attribute>
       <attribute name="Dialect">net.sf.hibernate.dialect.Oracle9Dialect</attribute>
       <!--<attribute name="UseOuterJoin">true</attribute>-->
       <attribute name="ShowSql">true</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>
      
      



      This fails to deploy due to:
      deployer: org.jboss.hibernate.har.HARDeployer@8890da
      status: Deployment FAILED reason: Failed to set HarUrl attribute: not found: HarUrl; - nested throwable: (javax.management.AttributeNotFoundException: not found: HarUrl)

      OK, so I tried adding a HarUrl attribute but got a different error. I can't find any documentation about this attribute. What is it?

      Thanks!

        • 1. 3779198
          tomislavr Newbie

          I have the same problem . How can I configure JBossMQ for DefaultJMSProvider and MQSeriesJMSProvider for MQ Series and how can I test it .

          in the Jmx-console I get only the JBSSMQProvider irrespective of changes in the jms-ds.xml and jboss-service.xml

          Can you post (Cut and Paste ) the config files in the Fourm

          Many thanks

          • 2. Re: using hibernate in jboss-4.0.0
            Emily Newbie

            fixing this line corrected the problem:

            • 3. Re: using hibernate in jboss-4.0.0
              Emily Newbie

              more changes to make this 4.0.0 compatible, and now it's working, for those interested:

              <server>
               <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
               <depends>jboss.jca:service=LocalTxCM,name=TxOracleDS</depends>
              
               <attribute name="SessionFactoryName">java:/HibernateFactory</attribute>
               <attribute name="DatasourceName">java:/TxOracleDS</attribute>
               <attribute name="Dialect">net.sf.hibernate.dialect.Oracle9Dialect</attribute>
               <attribute name="CacheProviderClass">net.sf.hibernate.cache.HashtableCacheProvider</attribute>
               <attribute name="Hbm2ddlAuto">update</attribute>
               </mbean>
              
              </server>
              
              


              • 4. Re: using hibernate in jboss-4.0.0
                dapeng wang Newbie

                Can you show a complete working example? Did you put the .HAR in your .EAR file? How do you access the SessionFactory? Where did you put the hibernate.hbm.xml?

                Thanks for any help.

                • 5. Re: using hibernate in jboss-4.0.0
                  beyarecords Novice

                   

                  "berkgypsy" wrote:
                  more changes to make this 4.0.0 compatible, and now it's working, for those interested:

                  <server>
                   <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
                   <depends>jboss.jca:service=LocalTxCM,name=TxOracleDS</depends>
                  
                   <attribute name="SessionFactoryName">java:/HibernateFactory</attribute>
                   <attribute name="DatasourceName">java:/TxOracleDS</attribute>
                   <attribute name="Dialect">net.sf.hibernate.dialect.Oracle9Dialect</attribute>
                   <attribute name="CacheProviderClass">net.sf.hibernate.cache.HashtableCacheProvider</attribute>
                   <attribute name="Hbm2ddlAuto">update</attribute>
                   </mbean>
                  
                  </server>
                  
                  



                  Hi,
                  i'm at the stage you were at when wrtting this article and well and truely stuck. My structure thus far is:

                  hibernate.har

                  inside the .har file I have two folders
                  1. meta-inf - containing hibernate-service.xml

                  2. test - containing my *.Class and *.hbm.xml files (Is this correct ?)
                  Do i have to call the test folder test.war or some such name?

                  In what file do i specify my mapresources? is it the hibernate-service.xml file itself? If so how do I specify the files.

                  I have scaned the available resources on this issue but the solutions are for different incarnations of jboss which have all have different implentations, and thus don't work.

                  I am currently running JBoss 3.2.6

                  many thanks for your help and time


                  Andrew

                  • 6. Re: using hibernate in jboss-4.0.0
                    Utkarsh Shah Newbie

                    Hello,
                    I am also getting the same error. Were you able to solve it? If yes please let me know the solution.

                    Thanks

                    • 7. Re: using hibernate in jboss-4.0.0
                      Utkarsh Shah Newbie

                      I am geting following error when I try to deploy hibernate Mbean,

                      org.jboss.deployment.DeploymentException: No Attribute found with name: MapResources


                      I tried to google for this problem but couldn't find any useful info.

                      My Abhyasika.har has following structure,
                      com <--This folder contains my package hierarchy with classes and hbm.xml files
                      META-INF <-- It contains hibernate-service.xml
                      hibernate.cfg.xml
                      hibernate.properties

                      The Exception:
                      org.jboss.deployment.DeploymentException: No Attribute found with name: MapResources
                      rces
                      at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.ja
                      va:340)
                      at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigura
                      tor.java:160)
                      at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java
                      :114)
                      at org.jboss.system.ServiceController.install(ServiceController.java:200
                      )
                      at sun.reflect.GeneratedMethodAccessor46.invoke(Unknown Source)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
                      sorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:324)
                      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
                      er.java:141)
                      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
                      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
                      java:242)
                      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
                      at $Proxy4.install(Unknown Source)
                      at org.jboss.deployment.SARDeployer.create(SARDeployer.java:208)
                      at org.jboss.deployment.MainDeployer.create(MainDeployer.java:889)
                      at org.jboss.deployment.MainDeployer.create(MainDeployer.java:881)
                      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:745)
                      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:709)
                      at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
                      sorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:324)
                      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
                      er.java:141)


                      Here is my hibernate-service.xml
                      <?xml version="1.0" encoding="UTF-8"?>
                      <!DOCTYPE server>
                      
                      <!-- Generated file - Do not edit! -->
                      
                      <server>
                       <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
                       <depends>jboss.har:service=HARDeployer</depends>
                       <depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends>
                       <attribute name="MapResources">com/utkarsh/abhyasika/hibernate/Category.hbm.xml
                       </attribute>
                       <attribute name="DatasourceName">java:/MySQLDS</attribute>
                       <attribute name="Dialect">net.sf.hibernate.dialect.MySQLDialect</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>
                       <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
                       <attribute name="CacheProviderClass">net.sf.hibernate.cache.HashtableCacheProvider</attribute>
                       <attribute name="Hbm2ddlAuto">update</attribute>
                       </mbean>
                      </server>

                      Let me know as to what could be problem?

                      Thanks
                      Utkarsh

                      • 8. Re: using hibernate in jboss-4.0.0
                        tomislavr Newbie

                        > My Abhyasika.har has following structure ,
                        > com <--This folder contains my package hierarchy with classes and
                        > hbm.xml files
                        > META-INF <-- It contains hibernate-service.xml
                        > hibernate.cfg.xml
                        > hibernate.properties

                        I don't know about the last two - I'm not using them, but for sure you have a problem because you are using attributes which now do not exist. For example, 'MapResources' att. is no longer required as Jboss will search inside .har for .hbm descriptors.

                        I'll give you a list of att. I found in Jboss source, so this is all you have now. Things have changed, and docs are not updated everywhere.

                        Also I've noticed a lot of questions about 'HarUrl' stuff - change mbean code att. to "org.jboss.hibernate.jmx.Hibernate" :)

                        Attributes:
                        datasourceName
                        dialect
                        sessionFactoryName
                        cacheProviderClass
                        cacheRegionPrefix
                        hbm2ddlAuto
                        defaultSchema
                        jdbcBatchSize
                        jdbcFetchSize
                        jdbcScrollableResultSetEnabled
                        queryCacheEnabled
                        querySubstitutions
                        maxFetchDepth
                        showSqlEnabled
                        getGeneratedKeysEnabled
                        username
                        password
                        TRANSACTION_MANAGER_STRATEGY
                        TRANSACTION_STRATEGY

                        hope this helps..

                        cheers,
                        Tomislav

                        • 9. Re: using hibernate in jboss-4.0.0
                          Yura Korotyshev Newbie

                          This is a full list of attributes:

                          Dirty
                          CacheProviderClass
                          CacheRegionPrefix
                          GetGeneratedKeysEnabled
                          SessionFactoryName
                          HarUrl
                          DefaultSchema
                          ShowSqlEnabled
                          QueryCacheEnabled
                          DatasourceName
                          Password
                          JdbcFetchSize
                          StateString
                          SessionFactoryRunning
                          JdbcBatchSize
                          JdbcScrollableResultSetEnabled
                          Hbm2ddlAuto
                          MaxFetchDepth
                          Name
                          QuerySubstitutions
                          Dialect
                          SessionFactoryInterceptor
                          Username

                          It's easy to find this in JBoss Web-Consol.
                          by default:
                          http://localhost:8080/web-console/

                          Just select System->JMX MBeans->jboss.har->jboss.har:servise=Hibernate and you will see all attributes and it's values.

                          • 10. Re: using hibernate in jboss-4.0.0
                            Raj Subramani Newbie

                            I got it all working with Apache Derby as the database server, without a hitch (so far).

                            First one needs to replace (in default/lib) the jboss-hibernate.jar that comes with JBoss4RC2 with the one from this wiki

                            http://www.jboss.org/wiki/Wiki.jsp?page=JBossHibernate

                            Rename jboss-hibernate-NEW.jar as jboss-hibernate.jar.

                            Also configure the MBean as mentioned in the wiki:

                            My MBean is configured as:

                            <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
                             <attribute name="DatasourceName">java:/DefaultDS</attribute>
                             <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
                             <attribute name="Dialect">net.sf.hibernate.dialect.DerbyDialect</attribute>
                             <attribute name="CacheProviderClass">net.sf.hibernate.cache.HashtableCacheProvider</attribute>
                            </mbean>
                            



                            If you are going to use the Apache Derby DB then there is no dialect support for this at the moment but the requried files can be got from here

                            [url=http://opensource.atlassian.com/projects/hibernate/browse/HB-1224][http://opensource.atlassian.com/projects/hibernate/browse/HB-1224[/url]

                            compiled and incorprated into the hibernate2.jar file in default/lib

                            Finally my jboss-app.xml file is as follows:

                            <!DOCTYPE jboss-app PUBLIC "-//JBoss//DTD J2EE Application 1.4//EN"
                             "http://www.jboss.org/j2ee/dtd/jboss-app_4_0.dtd">
                            <jboss-app>
                             <module>
                             <har>rlhibernate.har</har>
                             </module>
                             <module>
                             <ejb>rlhibernate.jar</ejb>
                             </module>
                            </jboss-app>
                            


                            The only thing I noticed is that this job-app.xml seems to go in as meta-inf/application.xml since my ear is created using an Ant script.

                            Doesn't seem to affect the deployment of the ear though.

                            Hope this helps.

                            Cheers
                            -raj

                            • 11. Re: using hibernate in jboss-4.0.0
                              fabio quimbay Newbie

                              But, If I don't use the *.hbm.xml files within the har file, How can I to refer this files without the attribute: MapResources in my hibernate-service.xml ?

                              • 12. Re: using hibernate in jboss-4.0.0
                                hjsad af Newbie

                                rajs1
                                Would you mind post what you do to make derby works as a database server, I get some issues that seems to be hard to resolve. thanks.

                                • 13. Re: using hibernate in jboss-4.0.0
                                  Dina Grover Newbie

                                  hi utkarshpune,

                                  ur problem will be solved when u remove all references to *hbm.xml files from hibernate-service.xml and put them in *.har file maintaining the class hierarchy.
                                  Atleast this will solve ur current problem but i am not sure that Hibernate will still work as i am grappling it with from last 2 days and everytime i solve one problem there is another one just round the corner.

                                  bye.
                                  hope it helps u.