Hi,

I am receiving the following error intermittently:  

javax.transaction.RollbackException: Already marked for rollback 
TransactionImpl:XidImpl

The Transaction manager code I have written is as follows:


  | import javax.naming.InitialContext;
  | import javax.naming.NamingException;
  | import javax.rmi.PortableRemoteObject;
  | import javax.transaction.HeuristicMixedException;
  | import javax.transaction.HeuristicRollbackException;
  | import javax.transaction.NotSupportedException;
  | import javax.transaction.RollbackException;
  | import javax.transaction.Status;
  | import javax.transaction.SystemException;
  | import javax.transaction.UserTransaction;
  | 
  | import org.apache.log4j.Logger;
  | 
  | import com.prototypeit.exception.DAORuntimeException;
  | 
  | public class TransactionManager {
  | 
  |     private static UserTransaction transaction = null;
  |     private static Logger log = Logger.getLogger(TransactionManager.class);
  |     
  |     public static void begin(){
  |             
  |             try {
  |                     InitialContext ctx = new InitialContext();
  |                     debug("Beginning a User transaction");
  |                     if(transaction == null){
  |                             debug("Transaction is null. So doing a new 
lookup to fetch the UserTransaction!");
  |                             Object o = 
ctx.lookup("java:comp/UserTransaction");
  |                             transaction = 
(UserTransaction)PortableRemoteObject.narrow(o, UserTransaction.class);
  |                     }
  |                     debug("Transaction Status Before begin(): 
"+transaction.getStatus());
  |                     if(transaction.getStatus() == 
Status.STATUS_NO_TRANSACTION){
  |                             debug("invoking transaction.begin");
  |                             transaction.begin();
  |                     }
  |                     debug("Transaction Status After begin(): 
"+transaction.getStatus());
  |             } catch (NamingException e) {
  |                     log.error(e.getMessage());
  |                     throw new DAORuntimeException(e);
  |             } catch (NotSupportedException e) {
  |                     log.error(e.getMessage());
  |                     throw new DAORuntimeException(e);
  |             } catch (SystemException e) {
  |                     log.error(e.getMessage());
  |                     throw new DAORuntimeException(e);
  |             }
  |     }
  |     
  |     public static void commit(){
  |             if(transaction != null){
  |                     try {
  |                                     debug("The Status while committing: "+ 
transaction.getStatus());
  |                                     transaction.commit();
  |                                     debug("The Status After committing: "+ 
transaction.getStatus() );
  |                     } catch (SecurityException e) {
  |                             log.error(e.getMessage());
  |                             rollback();
  |                             throw new DAORuntimeException(e);
  |                     } catch (IllegalStateException e) {
  |                             log.error(e.getMessage());
  |                             rollback();
  |                             throw new DAORuntimeException(e);
  |                     } catch (RollbackException e) {
  |                             log.error(e.getMessage());
  |                             rollback();
  |                             throw new DAORuntimeException(e);
  |                     } catch (HeuristicMixedException e) {
  |                             log.error(e.getMessage());
  |                             rollback();
  |                             throw new DAORuntimeException(e);
  |                     } catch (HeuristicRollbackException e) {
  |                             log.error(e.getMessage());
  |                             rollback();
  |                             throw new DAORuntimeException(e);
  |                     } catch (SystemException e) {
  |                             log.error(e.getMessage());
  |                             rollback();
  |                             throw new DAORuntimeException(e);
  |                     }
  |             }
  |             
  |     }
  |     
  |     public static void rollback(){
  |             
  |             if(transaction != null){
  |                     
  |                     try {
  |                             debug("The Status while rolling back: "+ 
transaction.getStatus());
  |                             transaction.rollback();
  |                             debug("The Status after rolling back: "+ 
transaction.getStatus());
  |                     } catch (IllegalStateException e) {
  |                             log.error(e.getMessage());
  |                             throw new DAORuntimeException(e);
  |                     } catch (SecurityException e) {
  |                             log.error(e.getMessage());
  |                             throw new DAORuntimeException(e);
  |                     } catch (SystemException e) {
  |                             log.error(e.getMessage());
  |                             throw new DAORuntimeException(e);
  |                     }
  |                     
  |             }
  |     }
  |     
  |     public static void debug(String message){
  |             if(log.isDebugEnabled()){
  |                     log.debug(message);
  |             }
  |     }
  | }
  | 

Any help is very much appreciated,
Thanks a lot,
-H

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3921225#3921225

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3921225


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to