3 Replies Latest reply on May 18, 2002 12:02 AM by David Jencks

    Sharing a Datasource

    David Streever Newbie

      I've got a call that goes to a Stateless Session Bean. In that bean I get a Datasource from a JNDI reference. I've also declared the reference in ejb-jar.xml and jboss.xml.

      == ejb-jar ==




      == jboss.xml ==

      Everything works fine until I call another Stateless Session bean from the initial bean that uses the same datasource.

      It seems to work fine if I don't get a datasource prior to the call to the other session bean but, the following fails.

      // get datasource in outer session bean
      // get local home to other session
      // get local interface to other session
      // get datasource
      // use datasource
      // return results to outer bean
      // use results and make a database call.

      If I wait to get the datasource until after I've made the call to the inner bean, it works.

      How can I share this datasource within the same context?
      When a connection is created from a datasource in this fashion, is it necessary to close the connection or is that handled by the container?

      Thanks for any input.