5 Replies Latest reply on Dec 17, 2006 6:02 PM by Balázs Végs?

    Unfinished local transaction was rolled back

    Balázs Végs? Newbie

      Hi there,

      i'm getting a lot of these messages in my log which is at DEBUG level. I really don't know why, i've played around with manually committing or rolling back transactions, setting setAutoCommit() true/false on the connection i'm using, but this keeps filling my logs. Any thoughts?

      Thanks!


      ---- server.log ---------------------------------------------

      2006-09-18 15:58:05,387 DEBUG [org.jboss.resource.connectionmanager.TxConnectionManager] Unfinished local transaction was rolled back.org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener@437d51a6[state=NORMAL mc=org.jboss.resource.adapter.jdbc.local.LocalManagedConnection@4d815146 handles=0 lastUse=1158587885376 permit=true trackByTx=false mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@64fef26a context=org.jboss.resource.connectionmanager.InternalManagedConnectionPool@1ddd40f3 xaResource=org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource@28d320d6 txSync=null]



        • 1. Re: Unfinished local transaction was rolled back
          Kevin Conner Master

          It looks like you have not terminated one of your connections by calling rollback or commit.

          • 2. Re: Unfinished local transaction was rolled back
            Balázs Végs? Newbie

             

            private String[] getFilterSessions(String uid) {
             Log.infomsg(this, "Getting filter session list [UID: "+uid+"]");
            
             String SQL="SELECT ...";
             PreparedStatement pstmt = null;
             try {
             conn = OracleHelper.vchConnectionFromPool();
             pstmt = conn.prepareStatement( SQL );
             ResultSet rs=pstmt.executeQuery();
             ...
             }
             catch (Exception ex) {
             ex.printStackTrace();
             }
             finally {
             try
             {
             if( pstmt != null )
             pstmt.close();
             conn.close();
             }
             catch (Exception e)
             {
             Log.errmsg( "Exception: " + e.getMessage() );
             }
             }
            


            getting connection with: (USE_CONNECTION_POOL() returns true)

            public static Connection vchConnectionFromPool() throws java.sql.SQLException, javax.naming.NamingException
             {
             if( USE_CONNECTION_POOL() )
             {
             InitialContext initCtx = new InitialContext();
             String JNDIName = "java:/jdbc/" + DB_CONNECTION_POOL();
             DataSource src = (DataSource) initCtx.lookup( JNDIName );
             return src.getConnection();
             }
            


            result:

            2006-12-17 21:18:29,549 INFO [STDOUT] 2: [xxx.xxx.xxx.Bean]: Getting filter session list [UID: asd-asda-sdasa333]
            2006-12-17 21:18:29,552 DEBUG [org.jboss.resource.connectionmanager.TxConnectionManager] Unfinished local transaction was rolled back.org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener@74f8f156[state=NORMAL mc=org.jboss.resource.adapter.jdbc.local.LocalManagedConnection@793a2cd7 handles=0 lastUse=1166386709549 permit=true trackByTx=false mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@5a56156e context=org.jboss.resource.connectionmanager.InternalManagedConnectionPool@49991717 xaResource=org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource@61bb0cc0 txSync=null]


            if i do a commit/rollback before conn.close() in the finally block, the result is:

            You cannot rollback with autocommit set!


            from j2se doc: (http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Connection.html)

            Note: By default a Connection object is in auto-commit mode, which means that it automatically commits changes after executing each statement.


            • 3. Re: Unfinished local transaction was rolled back
              Balázs Végs? Newbie

              i'm sorry i forgot to say i'm very thankful for your quick reply, and really apreciate your help! i was in such a hurry.
              thanks again!

              • 4. Re: Unfinished local transaction was rolled back
                Kevin Conner Master

                Yes, that is correct. By default all connections opened in a non transactional context will have auto commit set to true.

                However, you should only be seeing this error from a connection which has had its auto commit set to false.

                • 5. Re: Unfinished local transaction was rolled back
                  Balázs Végs? Newbie

                  thanks for your help. fortunately your comments made me think of my code in a new way and for some reason i tried to set autocommit to true with every retrieval of this connection object (in vchConnectionFromPool()).
                  this did help.
                  possible reason i think is that this method is static and always returns the same connection reference, which - if previously used in a transaction - was set to autocommit false.
                  i dont know if this makes sense, but whatever: the problem is solved.
                  thanks for hints, advice and help.