[jboss-user] [JBoss Seam] - transaction problem

dreuzel do-not-reply at jboss.com
Tue Jan 15 06:59:03 EST 2008


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 ?

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

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



More information about the jboss-user mailing list