2 Replies Latest reply on Jan 14, 2005 5:28 AM by beyarecords

    From Tomcat to JBoss, a hibernate application

    leebase

      I have an application that runs fine under Tomcat....it uses hibernate.

      When I try to deploy on Jboss 4.0.0 I'm getting class not found errors....and mention of not being able to find the /hibernate.cfg.xml

      I read that Hibernate is built into JBoss...is there something I need to do to migrate this app?

      Lee

        • 1. Re: From Tomcat to JBoss, a hibernate application
          samfra

          I think you don't know how to use Hibernate with jboss.
          Read first the doc...

          there is no hibernate.cfg.xml but an hibernate-service.xml that must be include in a HAR archive.

          • 2. Re: From Tomcat to JBoss, a hibernate application
            beyarecords

            Lee,
            in my hibernate.har folder the structure is:

            hibernate.har
            -hibernate.cfg.xml
            -META-INF/hibernate-service.xml
            -test/ (*.hbm.xml,*.class)
            -WEB-INF/lib/here I have my database driver and ehcache.(jar/xml)

            hibernate.cfg.xml

            <hibernate-configuration>
            
             <session-factory>
             <!-- Use a Tomcat JNDI datasource -->
             <!--<mapping resource="test/User.hbm.xml"/>
             <mapping resource="test/Artist.hbm.xml"/>
             <mapping resource="test/ArtistImages.hbm.xml"/>
             <mapping resource="test/Stock.hbm.xml"/>
             <mapping resource="test/StockImages.hbm.xml"/>
             <mapping resource="test/Order.hbm.xml"/>
             <mapping resource="test/OrderItem.hbm.xml"/>-->
            
             <class-cache class="test.Order" usage="transactional"/>
             <collection-cache collection="test.Order.OrderItems" usage="transactional"/>
             <class-cache class="test.Artist" usage="transactional"/>
             <collection-cache collection="test.Artist.ArtistImages" usage="transactional"/>
             <class-cache class="test.User" usage="transactional"/>
             <collection-cache collection="test.User.ArtistChoice" usage="transactional"/>
             <class-cache class="test.Stock" usage="transactional"/>
             <collection-cache collection="test.Stock.StockImages" usage="transactional"/>
             </session-factory>
            
            </hibernate-configuration>
            


            I have quoted out the mapping resource lines because the *.hbm.xml files are automatically picked up. But it will not harm if you do decide to list them.

            hibernate-service.xml
            <server>
             <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
             <depends>jboss.jca:service=RARDeployer</depends>
             <depends>jboss.jca:service=LocalTxCM,name=PostgresDS</depends>
             <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
             <attribute name="DatasourceName">java:/PostgresDS</attribute>
             <attribute name="Dialect">net.sf.hibernate.dialect.PostgreSQLDialect</attribute>
             <attribute name="CacheProviderClass">net.sf.ehcache.hibernate.Provider</attribute>
             <!-- Turn this on and set the value to update if you want all the tables to be updated by hibernate -->
             <!-- or create-drop if you want the tables to be re-generated -->
             <attribute name="Hbm2ddlAuto"></attribute>
             <attribute name="ShowSqlEnabled">true</attribute>
             <attribute name="JdbcBatchSize">25</attribute>
             </mbean>
            </server>
            


            I hope this helps

            beya!