3 Replies Latest reply on Oct 27, 2004 2:27 PM by natebowler

    afterCompletion() & database connection closing

    Dan Walters Newbie

      I'm using JBoss v3.0.4 with TopLink v9.0.3.

      TopLink uses the JTA Synchronization interface, executing SQL statements in beforeCompletion() and closing the database connections in afterCompletion(). They're used this approach for a long time, and (with a little tweaking) I've used it successfully on WebLogic 5/6/7, 9iAS, and JBoss v2.4.

      The problem I'm running into with JBoss v3 is that when the connection is closed by JBoss sometime after beforeCompletion() but before afterCompletion(), so when close is called I get an "IllegalStateException: Alredy committed."

      This is with an Oracle 8i database, the latest thin JDBC driver, and a local managed connection pool (non-XA) configured similar to the sample oracle-service.xml.

      So, is this behavior that should change in JBoss - allowing resources to be closed in afterCompletion() - or is it not correct? The specs seem a little vague, but it may be best to remain consistent with other implementations.

      Thanks,
      -Dan

        • 1. Re: afterCompletion() & database connection closing
          David Jencks Master

          Can you provide any more concrete information about what is happening, perhaps a log excerpt and anything you know about the actions the toplink code does? What you say doesn't make any sense to me yet, because jboss never closes connections for you, ever. In fact it is a spec requirement that you can leave them open between method calls, and my tests indicate this works.

          Also, closing a connection does not have any relationship to committing a transaction the connection may be enrolled in.

          • 2. Re: afterCompletion() & database connection closing
            Dan Walters Newbie

            David:

            I've attached a trace which shows what happens in one transaction, with toplink logging and trace logging enabled on tm, resource, and ejb.

            Eventually, if I run enough transactions, I wind up with the following exception:

            org.jboss.util.NestedSQLException: No ManagedConnections Available!; - nested throwable: (javax.resource.ResourceException: No ManagedConnections Available!)
            at org.jboss.resource.adapter.jdbc.local.LocalDataSource.getConnection(LocalDataSource.java:106)
            at oracle.toplink.jndi.JNDIConnector.connect(Unknown Source)
            at oracle.toplink.sessions.DatabaseLogin.connect(Unknown Source)

            My current workaround involves letting TopLink do its own connection pooling, but I'd much rather leave that to the app server.

            Thanks for your assistance,
            -Dan

            • 3. Re: afterCompletion() & database connection closing
              natebowler Newbie

              This is the exact same problem I am having, but this thread died without an explanation of the fix.

              What was the trick here? How did you modify the TopLink JTSSynchronizationListener to play nice with JBoss?

              Nate