Jure,

As I understand it you are not meant to directly access con.commit() or
con.rollback() methods from 
within an EJB. If you want to do Bean demarcated transactions, then you
should use an external (to postgres) transaction manager
via the javax.transaction.UserTransaction interface and use its commit() and
rollback() methods.

see section 11 of the EJB spec - specifically section 11.3.3

cheers
Perryn 

-----Original Message-----
From: Jure Lodrant [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 5 July 2001 14:58
To: [EMAIL PROTECTED]
Subject: [JBoss-user] rollback jdbc transaction


Hi,

here is my problem:

I have a sample session bean connecting to a postgres datasource (Using
JBOSS 
2.2.2 here). A bussiness 
method goes like this:

try {
         con.setAutoCommit(false);
         updateOrderItem(productId, orderId);
         updateInventory(productId, quantity);
         con.commit();
      } catch (Exception ex) {
          try {
                  
            con.rollback();
             throw new EJBException("Transaction failed: " +
ex.getMessage());
          } catch (Throwable sqx) {
              throw new EJBException("Rollback failed: " +
sqx.getMessage());
          }
      }
   } 


if transaction is committed, all is OK. When an application exception occurs

(e.g. updateInventory throws an exception) and con.rollback() is called, the

client gets an exception:

RemoteException occurred in server thread; ne
sted exception
is:
        java.rmi.ServerException: Transaction rolled back
java.rmi.ServerException: RemoteException occurred in server thread; nested 
exception is:
        java.rmi.ServerException: Transaction rolled back
java.rmi.ServerException: Transaction rolled back
        at 
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteC
all.java:248)
        at 
sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
        at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:128)
        at 
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker_Stub.invoke(Unknown 
Source)
        at 
org.jboss.ejb.plugins.jrmp.interfaces.StatelessSessionProxy.invoke(Stateless
SessionProxy.java:188)
        at $Proxy1.ship(Unknown Source)
        at warehouse.test.WarehouseClient.main(WarehouseClient.java:37)

The server log is empty, like nothing happened.

The rollback is only supposed to throw an SQLException in case of db backend

problems. What am I doing wrong here?


Jure

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to