3 Replies Latest reply on Apr 29, 2004 5:19 AM by columod

    datasource dependency

    columod Newbie

      hi all,
      i've deployed a (hibernate) sar which works fine, however if i restart jboss without deleting the sar from the deploy directory i get an error saying it could't find the databsource when jboss starts up.
      if i delete the sar, restart jboss and then redeploy everything is fine leading me to believe i need to make my sar dependent on the datasource so that jboss doesn't attempt to load it until after the datasource is loaded.
      does anybody know how i would do this? any help would be greatly appreciated.
      ===============================================

      the error is as follows :

      15:24:03,215 FATAL [DatasourceConnectionProvider] Could not find datasource: java:/cjdbc-gmmhDS
      javax.naming.NameNotFoundException: cjdbc-gmmhDS not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:282)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)


      note : the datasource is successfully loaded later in the startup :

      5:24:10,571 INFO [TxConnectionManager] Started jboss.jca:service=LocalTxCM,name=cjdbc-gmmhDS
      15:24:10,574 INFO [gmmhDS] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:service=LocalTxCM,name=gmmhDS to JNDI name 'java:/gmmhDS'
      15:24:10,575 INFO [TxConnectionManager] Started jboss.jca:service=LocalTxCM,name=gmmhDS


      ===============================================

      my jboss-service.xml file in the sar looks like this :

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE server>

      <!-- Generated file - Do not edit! -->



      jboss.jca:service=RARDeployer
      com/test/ReplyPath.hbm.xml
      java:/hibernate/gmmh
      java:/cjdbc-gmmhDS
      net.sf.hibernate.dialect.MySQLDialect
      true
      true
      UserTransaction
      net.sf.hibernate.transaction.JTATransactionFactory
      net.sf.hibernate.transaction.JBossTransactionManagerLookup



        • 1. Re: datasource dependency
          columod Newbie

          oops, heres the full jboss-service.xml file

          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE server>

          <!-- Generated file - Do not edit! -->



          jboss.jca:service=RARDeployer
          com/yahoo/gmmh/hibernate/MobileOperator.hbm.xml
          java:/hibernate/gmmh
          java:/cjdbc-gmmhDS
          net.sf.hibernate.dialect.MySQLDialect
          true
          true
          UserTransaction
          net.sf.hibernate.transaction.JTATransactionFactory
          net.sf.hibernate.transaction.JBossTransactionManagerLookup


          • 2. Re: datasource dependency
            d d Newbie

            the hibernate mbean config probably needs (though I still cannot get the hibernate service to work for myself :) )

            <depends>jboss.jca:service=RARDeployer</depends>
             <depends>jboss.jca:service=LocalTxCM,name=gmmhDS</depends>


            see http://hibernate.bluemars.net/66.html .. it is a little less than 1/2 way down the page

            • 3. Re: datasource dependency
              columod Newbie

              thanks a lot!! finally got that working ;-)

              not sure why it's not working for you but if it helps, here is my ant/xdoclet task :

               <!-- =================================================================== -->
               <!-- Invoke XDoclet's hibernate -->
               <!-- =================================================================== -->
               <target name="generate-hibernate" depends="compile-hibernate">
              
               <echo>+---------------------------------------------------+</echo>
               <echo>| |</echo>
               <echo>| RUNNING HIBERNATEDOCLET |</echo>
               <echo>| |</echo>
               <echo>+---------------------------------------------------+</echo>
              
               <hibernatedoclet
               destdir="${gen-src.dir}"
               mergedir="${merge.dir}"
               excludedtags="@version,@author,@todo,@see,@desc"
               addedtags="@xdoclet-generated at ${TODAY},${copy.right},@author ${author},@version ${version}"
               verbose="false">
              
               <fileset dir="${java.src.dir}">
               <include name="**/hibernate/*.java"/>
               </fileset>
              
               <hibernate version="2.0"/>
              
               <jbossservice
               destdir="${gen-conf.dir}"
               servicename="${service.name}"
               jndiname="java:/${hibernate.jndi.name}"
               datasource="java:/${cjdbc.database.jndi.name}"
               dialect="${database.dialect}"
               useOuterJoin="true"
               showSql="true"
               transactionManagerStrategy="net.sf.hibernate.transaction.JBossTransactionManagerLookup"
               transactionStrategy="net.sf.hibernate.transaction.JTATransactionFactory"
               userTransactionName="UserTransaction"
               >
               <configparam name="depends" value="jboss.jca:service=LocalTxCM,name=${cjdbc.database.jndi.name}"/>
               </jbossservice>
               </hibernatedoclet>
              
               <!-- Need to rename the file as other sar have jboss-service.xml files too. -->
               <move file="${gen-conf.dir}/jboss-service.xml" tofile="${gen-conf.dir}/hibernate-jboss-service.xml"/>
              
               </target>
              



              hope this helps, thanks again.
              colum.