2 Replies Latest reply on Sep 27, 2004 3:37 AM by nimrod

    a issue of deploying the Hibernate-based application on JBos

    nimrod Newbie

      Following the "Using Hibernate with JBoss" on http://www.hibernate.org/66.html , I created a sar package and deployed it to JBoss's default/deploy folder.

      The sar package includes the following files:

      /com/xx/hibernate/po/Teacher.class
      /com/xx/hibernate/po/Student.class
      /com/xx/hibernate/po/Book.class
      /com/xx/hibernate/po/Teacher.hbm.xml
      /com/xx/hibernate/po/Student.hbm.xml
      /com/xx/hibernate/po/Book.hbm.xml
      /hibernate.cfm.xml


      and the file related to JBoss
      /META-INF/jboss-service.xml

      the jboss-server.xml looks like:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE server>
      <!-- Generated file - Do not edit! -->


      jboss.jca:service=RARDeployer
      jboss.jca:service=LocalTxCM,name=myHibernateSqlServerDB
      com/xx/hibernate/po/Book.hbm.xml,com/xx/hibernate/po/Student.hbm.xml,com/xx/hibernate/po/Teacher.hbm.xml
      java:/HibernateFactory
      java:/myHibernateSqlServerDB
      net.sf.hibernate.dialect.SQLServerDialect
      true
      true
      UserTransaction
      net.sf.hibernate.transaction.JTATransactionFactory
      net.sf.hibernate.transaction.JBossTransactionManagerLookup



      and the defaul/deploy/mssql-ds.xml looks like:

      <local-tx-datasource>
      <jndi-name>myHibernateSqlServerDB</jndi-name>
      <connection-url>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=hibernate;SelectMethod=cursor</connection-url>
      <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
      <user-name>sa</user-name>


      <type-mapping>MS SQLSERVER2000</type-mapping>

      </local-tx-datasource>





      I got a error message when starting the JBoss:
      FATAL [DatasourceConnectionProvider] Could not find datasource: java:/myHibernateSqlServerDB
      javax.naming.NameNotFoundException: myHibernateSqlServerDB not bound.......


      and if I removed the sar package from defaul/deploy folder, the Datasource just worked well.

      So, why did the error happen when deploying my sar package???


        • 1. Re: a issue of deploying the Hibernate-based application on
          nimrod Newbie

          The jboss-service.xml looks like:

          <server>
           <mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=myHibernate">
           <depends>jboss.jca:service=RARDeployer</depends>
           <depends>jboss.jca:service=LocalTxCM,name=myHibernateSqlServerDB</depends>
           <attribute name="MapResources">com/xx/hibernate/po/Book.hbm.xml,com/xx/hibernate/po/Student.hbm.xml,com/xx/hibernate/po/Teacher.hbm.xml</attribute>
           <attribute name="JndiName">java:/HibernateFactory</attribute>
           <attribute name="Datasource">java:/myHibernateSqlServerDB</attribute>
           <attribute name="Dialect">net.sf.hibernate.dialect.SQLServerDialect</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>


          • 2. Re: a issue of deploying the Hibernate-based application on
            nimrod Newbie

            the mssql-ds.xml looks like:

            <datasources>
             <local-tx-datasource>
             <jndi-name>myHibernateSqlServerDB</jndi-name>
             <connection-url>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=hibernate;SelectMethod=cursor</connection-url>
             <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
             <user-name>sa</user-name>
             <password></password>
             <metadata>
             <type-mapping>MS SQLSERVER2000</type-mapping>
             </metadata>
             </local-tx-datasource>
            </datasources>