6 Replies Latest reply on Sep 29, 2003 2:17 AM by bala_m

    connection closed after method call returned from a session

    bala_m Newbie

      i'm using a stateless session bean to retrieve a connection to mysql DB. this is running in jboss 3.2.1_tomcat_4.1.24 This bean is called from the servlet. Bean returns the connection object to the servlet. the transaction type of bean is cmp. The problem is After the connection returned by the bean to the servlet.Server gives

      [CachedConnectionManager] Successfully closed a connection for you.
      Please close them yourself:

      with the stack trace. Actually i called the bean to retrieve connection to execute statements in the servlet. But the connection is closed by CachedConnectionManager. this bean is working in weblogic server.
      cachedconnectionmanager closes the connection after the method call. how to tune off this behaviour in jboss.

      any ideas are appreciated.

      thanx in advance

        • 1. Re: connection closed after method call returned from a sess
          micke Novice

          The connection is a resource managed by the transaction spanning the bean method you called.
          The ConnectionManager will close any connection you failed to close when this tx ends (end of call).

          You could try to set 'SpecCompliant' to 'true' in transation-service.xml to notify Jboss
          not to close any open connections when returning from method call.

          Or maybe considering getting the connection from the DataSource directly
          in the servlet since it is used in it anyway.

          /micke

          • 2. Re: connection closed after method call returned from a sess
            bala_m Newbie

            Since my connection bean is container managed. I tried by giving not supportted attribute. still it's not working. also i changed to true in transaction.xml but
            the sql exception is

            "Connection handle is not currently associated with a ManagedConnection"

            If i called the data source directly then ok. But my we are using a bean to retrieven the connection.

            is there any ideas are appreciated
            thanx for reply
            -bala

            • 3. Re: connection closed after method call returned from a sess
              micke Novice

              I am still not sure what you are trying to do. I can see the ConnectionManager complaining if there is no tx associated to the connection. You could change, (or add), your DataSource to not be aware of any transactions. Try adding a new child config for the DataSource using <no-tx-datasource>.


              /micke

              • 4. Re: connection closed after method call returned from a sess
                bala_m Newbie

                i'm explaining in detail.

                i'm using a stateless session bean for DBConnection. i'm using mysql DB.This bean is called from the servlet. i have obtained the reference of the bean in servlet. so, i call the method defined in the bean. Only one method is defined in bean which contains(5 lines of code) the lookup of the jndi datasource.connection is obtained in the bean. i'm returning the connection from the bean to the servlet.
                It is a container managed bean.first i didn't specified container transaction attribute in the descriptor. I got the error of cachedconnectionmanager successfully closed the connection. and in the exception i caught is"connection has been closed and is unusable".

                i hv tried as ur tips. but the same error occured.

                i hope now the problem definition is ok.

                thanx

                • 5. Re: connection closed after method call returned from a sess
                  micke Novice

                  You can not do that. The web app and the ejb app could run on different VMs and on different boxes. Just wrap the data source lookup and in a helper class if you want to use another class to get the connection for the servlet. Or, you could move the db calls to the ejb app.

                  /micke

                  • 6. Re: connection closed after method call returned from a sess
                    bala_m Newbie

                    hi,
                    thanks a lot for the response. i'm convinced. thanks.

                    -bala