0 Replies Latest reply on Jan 15, 2008 6:59 AM by dreu zel

    transaction problem

    dreu zel Novice

      I'm using JTA transaction
      and try to manage my transactions myself (many independent updates)


      using seam 2.0.0.ga


       <core:init debug="@debug@" jndi-pattern="@jndiPattern@" transaction-management-enabled="false" />
       conversation-timeout="12000000" -->
       <core:manager concurrent-request-timeout="5000000"
       conversation-timeout="200000000"
       conversation-id-parameter="cid"/>
      



      i use following code to start the transaction
       UserTransaction tx=null;
       tx=Transaction.instance();//get the UserTransaction from seam
       // transaction handling
       try {
       if (tx!=null) tx.begin();
       } catch (Exception er )
       {errcod=er;
       String errmsg=er.getClass().getSimpleName() +" err: "+ er.getMessage();
       log.error(env+" starting transaction failed "+ errmsg);
       }
       try {
       I'm handling the transaction here ;
       try {
       em.flush();
       } catch (Exception er )
       {errcod=er;
       String errmsg=er.getClass().getSimpleName() +" err: "+ er.getMessage();
       log.error(env+" Flushing the transaction transaction failed "+ errmsg);
       }
      
       try {
       if (tx!=null) tx.commit();
       } catch (Exception er )
       {errcod=er;
       String errmsg=er.getClass().getSimpleName() +" err: "+ er.getMessage();
       log.error(env+" Commiting transaction failed "+ errmsg);
       }
      
      
       } catch (Exception er) {
       String errmsg=er.getClass().getSimpleName() +" err: "+ er.getMessage();
       log.error(env+" transaction error "+ errmsg);
       try {//rollback cover
       if (tx!=null) tx.rollback(); //if (!Transaction.instance().isActive())
       else if (ses!=null) txn.rollback();
       else em.getTransaction().rollback();
       } catch (Exception erx)
       {errcod=erx;
       String erxmsg=erx.getClass().getSimpleName() +" err: "+ erx.getMessage();
       log.error(env+" Rollback transaction failed "+ erxmsg +" From "+ errmsg);
       }
       }
       if (ses==null)
       { if (!(em.isOpen())) log.info("em session closed !");
       }
      
       }
      
      



      I'm trying to trap for every error
      I'm failing on tx.begin();

      how can I create the transaction ?