-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: reuse same transaction hit error in JBoss
PostPosted: Wed Jul 23, 2008 6:06 am 
Beginner
Beginner

Joined: Tue Jun 17, 2008 12:14 am
Posts: 21
I have Java/HIbernate apps. When run in Eclipse/JAR file with this, it works fine.

Code:
public void saveToDatabase() throws Exception
{
    Transaction txReporting = null;        
    try{   
   txReporting = sesReporting.beginTransaction(); 
                ...             
                txReporting.commit();
         } catch (Exception e) {
   if (txReporting != null) {
       // Something went wrong; discard all partial changes
       txReporting.rollback();                
                    // nested try-catch loop to catch all errors
       try{
      // for logging purpose
      txReporting = sesReporting.beginTransaction();
                   ...
                                 txReporting.commit();
              } catch (Exception ex) {
                 throw ex;
              }
           }
           throw e;
       }       
   }


But when I throw this into JBoss, I hit:

Quote:
2008-07-23 17:46:04,291 DEBUG [org.hibernate.util.JDBCExceptionReporter] Cannot open connection [???]
org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImple < ac, BasicAction: acc550a:c94:4886fda0:41 status: ActionStatus.ABORT_ONLY >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: acc550a:c94:4886fda0:41 status: ActionStatus.ABORT_ONLY >)
...
Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: acc550a:c94:4886fda0:41 status: ActionStatus.ABORT_ONLY >
at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:304)
at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:396)
at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)
... 53 more
2008-07-23 17:46:04,307 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: null
2008-07-23 17:46:04,307 ERROR [org.hibernate.util.JDBCExceptionReporter] Transaction is not active: tx=TransactionImple < ac, BasicAction: acc550a:c94:4886fda0:41 status: ActionStatus.ABORT_ONLY >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: acc550a:c94:4886fda0:41 status: ActionStatus.ABORT_ONLY >)
2008-07-23 17:46:04,307 ERROR [STDERR] org.hibernate.exception.GenericJDBCException: Cannot open connection


anyone?
is this called "multiple one-phase" : http://wiki.jboss.org/wiki/Multiple1PC ?

I thought using 2 separate transactions is required MSDTC (change <local-tx-datasource> to <xa-datasource>. )?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 23, 2008 7:02 am 
Beginner
Beginner

Joined: Tue Jun 17, 2008 12:14 am
Posts: 21
some similar issues are:
1) connection time out http://www.jboss.com/?module=bb&op=viewtopic&t=87750(but it only happend on re-used txn)
2) JBoss is obsolete http://www.jboss.com/?module=bb&op=viewtopic&t=111919(but my is 4.2.2)

when i do this in between code:

Code:
txReporting.rollback();
if(txReporting.wasRolledBack())
           System.out.printf("txReporting.wasRolledBack \n");
if(txReporting.isActive())
   System.out.printf("txReporting.isActive \n");   



It never show "txReporting.isActive" after txn.rolledback. But there's no option/method to set it to active?

anyone?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 23, 2008 7:58 pm 
Beginner
Beginner

Joined: Tue Jun 17, 2008 12:14 am
Posts: 21
anyone?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 3:17 am 
Beginner
Beginner

Joined: Tue Jun 17, 2008 12:14 am
Posts: 21
Is this the limitation of JBoss JTX on local-txn:

Quote:
When more than one recoverable resource is involved in the transaction, management of the commit gets more complicated. Simply asking each of the recoverable resources to commit changes to stable storage is not enough to maintain the atomic property of the transaction. The reason for this is that if one recoverable resource has committed and another fails to commit, part of the transaction would be committed and the other part rolled back.

To get around this problem, the two-phase XA protocol is used.


http://docs.jboss.org/admin-devel/Chap4.html?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 27, 2008 12:20 am 
Beginner
Beginner

Joined: Tue Jun 17, 2008 12:14 am
Posts: 21
anyone?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.