1 Reply Latest reply on Jun 15, 2005 11:50 AM by wcydaip

    TransactionException but no Rollback ?!?!

    exzensior

      I configured one of my SessionBean functions to be in a transaction

      <assembly-descriptor >
       <container-transaction>
       <method>
       <ejb-name>KontoService</ejb-name>
       <method-name>Buchung</method-name>
       </method>
       <trans-attribute>RequiresNew</trans-attribute>
       </container-transaction>
       </assembly-descriptor>
      


      The function Buchung works fine. Database_1 is local and database_2 on some server.

      // Buchung von Konto_1 auf Konto_2
       public void Buchung(Integer KNr_1, Integer KNr_2, Double Betrag)
       {
       DB_2.ejb.Server.interfaces.KontoLocalHome kontoHome = (DB_2.ejb.Server.interfaces.KontoLocalHome) ServiceLocator
       .getServiceLocator().lookup(DB_2.ejb.Server.interfaces.KontoLocalHome.JNDI_NAME,
       DB_2.ejb.Server.interfaces.KontoLocalHome.class);
      
       DB_2.ejb.Server.interfaces.Konto2LocalHome konto2Home = (DB_2.ejb.Server.interfaces.Konto2LocalHome) ServiceLocator
       .getServiceLocator().lookup(DB_2.ejb.Server.interfaces.Konto2LocalHome.JNDI_NAME,
       DB_2.ejb.Server.interfaces.Konto2LocalHome.class);
       try {
       Double kontoKontostand_2 = null;
       DB_2.ejb.Server.interfaces.Konto2Local konto2Local_2 = null;
       DB_2.ejb.Server.interfaces.KontoLocal kontoLocal_2 = null;
       DB_2.ejb.Server.interfaces.KontoLocal kontoLocal_1 = kontoHome.findByPrimaryKey(KNr_1);
       Double kontoKontostand_1 = kontoLocal_1.getKontostand();
      
       konto2Local_2 = konto2Home.findKonto2ByKontonummer2(KNr_2);
       kontoKontostand_2 = konto2Local_2.getKontostand2();
      
       Double kontoKontostand_1_neu = new Double(kontoKontostand_1.doubleValue()- Betrag.doubleValue());
       Double kontoKontostand_2_neu = new Double(kontoKontostand_2.doubleValue()+ Betrag.doubleValue());
      
      
       kontoLocal_1.setKontostand(kontoKontostand_1_neu);
      
       // ca. 30sec break for deactivating the Connection to database_2
       long t1 = System.currentTimeMillis();
       int a= 0;
       for ( double i = 0; i<5000000000.0; i++){a++; }
       System.out.println(System.currentTimeMillis() - t1);
      
      
       konto2Local_2.setKontostand2(kontoKontostand_2_neu);
      
      
      
       System.out.println("TRALALALALAL");
      
       }
       catch (FinderException e) {e.printStackTrace();}
      
      
       }
      





      When i try to find out whether the Trans. works or not I deactivate the networkconnection to database_2. So the container should rollback the change done in database_1, because it should commit eather both commands ore none of them. Unfortunately it's not working..means there is not rollback for the data in database_1 allthough the second "UPDATE" command (for database_2) hase not been commited.


      2005-06-15 11:19:03,771 INFO [STDOUT] TRALALALALAL
      2005-06-15 11:19:03,771 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.Konto] Executing SQL: UPDATE konto SET kontostand=? WHERE kontonummer=?
      2005-06-15 11:19:03,771 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.Konto2] Executing SQL: UPDATE konto2 SET kontostand2=? WHERE kontonummer2=?
      2005-06-15 11:19:03,786 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.parentTraceEnabled=true
      2005-06-15 11:19:03,786 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.nestedTraceEnabled=false
      2005-06-15 11:19:03,786 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.detectDuplicateNesting=true
      2005-06-15 11:19:03,786 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackException in method: public abstract void DB_2.ejb.Service.interfaces.KontoService.Buchung(java.lang.Integer,java.lang.Integer,java.lang.Double) throws java.rmi.RemoteException, causedBy:
      org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=WS12/21, BranchQual=, localId=21] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: Store failed; CausedByException is:
       Communication link failure: java.net.SocketException, underlying cause: Connection reset by peer: socket write error
      
      ** BEGIN NESTED EXCEPTION **
      
      java.net.SocketException
      MESSAGE: Connection reset by peer: socket write error
      
      STACKTRACE:
      
      java.net.SocketException: Connection reset by peer: socket write error
       at java.net.SocketOutputStream.socketWrite0(Native Method)
       at java.net.SocketOutputStream.socketWrite(Unknown Source)
       at java.net.SocketOutputStream.write(Unknown Source)
       at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
       at java.io.BufferedOutputStream.flush(Unknown Source)
       at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:1764)
       at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:1727)
       at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1148)
       at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
       at com.mysql.jdbc.Connection.execSQL(Connection.java:2251)
       at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1772)
       at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1619)
       at org.jboss.resource.adapter.jdbc.Wrapped....



      Anyone got any ideas on that ? I use:

      JBOSS 4.0.1sp1
      MySQL 4.0.13

      Windows XP Prof