Atomikos Forum

Issue with User Transaction taking a long time

On analysis, found that there is an internal refresh and recovery mechanism that is initiated on begin() call. This refresh takes time to complete its execution due to which actual thread is stuck. Sometimes it also throws internal exceptions like ERROR in Recovery. See Logs from tm.out below. On further analysis found that atomikos is internally creating an object of UserTransactionImpl for managing transactions. However Atomikos documentation suggest that web application should not use UserTransactionImpl. Instead it should use J2eeUserTransaction (http://www.atomikos.com/downloads/transactions-essentials/com/atomikos/AtomikosTransactionsEssentials/javadoc/3.7/com/atomikos/icatch/jta/UserTransactionImp.html).

Can you please help on how we can configure J2eeUserTransaction in tomcat? I am unable to find any documentation for the same. Please see below for our current configuration.

server.xml
...
<Resource name="UserTransaction" global="UserTransaction" type="javax.transaction.UserTransaction" factory="com.atomikos.icatch.jta.UserTransactionFactory"/>
...
 <Listener className="com.atomikos.tomcat.AtomikosLifecycleListener"/>
...

jta.properties

com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory
com.atomikos.icatch.console_file_name = tm.out
com.atomikos.icatch.log_base_name = tmlog
com.atomikos.icatch.tm_unique_name = com.atomikos.spring.jdbc.tm
com.atomikos.icatch.log_base_dir=atomikos_logs
com.atomikos.icatch.output_dir=atomikos_logs
com.atomikos.icatch.console_log_level = WARN
com.atomikos.icatch.default_jta_timeout = 180000
com.atomikos.icatch.max_timeout = 300000

Java code
Context initContext = new InitialContext();
ut = (UserTransaction) initContext.lookup(finalLookupString.toString());
ut.begin();
ps123 Send private email
Monday, June 10, 2013
 
 
Hi,

If I remember correctly then Tomcat would no longer need a separate UserTransaction configuration provided that the supplied TransactionManager implements UserTransaction.

So our recent release(s) we've improved the UserTransactionManager class to also implement UserTransaction and it can be configured as suggested here:

http://www.atomikos.com/Documentation/Tomcat7Integration35

I guess this would be a better way of dealing with this rather than using J2eeUserTransaction.

Can you give that a try?

HTH
Guy Pardon Send private email
Saturday, June 15, 2013
 
 
Thanks Guy for helping out. Our atomikos version is 3.6. And we tried configuring the TransactionManager but it is not working. Our tomcat version is 7.

Can you please confirm if we can configure the changes you suggested in 3.6? or if there is another way of using J2eeUserTransaction it with 3.6 version of atomikos.

If use below code, I was able to initialize Transaction. Wanted to check if we can integrate this code with tomcat startup.

UserTransactionService uts = new UserTransactionServiceImp();
        TSInitInfo info = uts.createTSInitInfo();
        
        System.out.println("UserTransactionService instance created: " + uts);
        
        //startup of transaction service
        uts.init ( info );
        System.out.println("UserTransactionService initialization done: " + uts);
        
        //now, the UserTransaction is available as follows:
        javax.transaction.UserTransaction utx = uts.getUserTransaction();
        System.out.println("UserTransaction: " + utx);
        
        try {
            utx.begin();
        } catch (NotSupportedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SystemException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }finally{
            try {
                utx.rollback();
            } catch (IllegalStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SecurityException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SystemException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        
        //shutdown the transaction service,
        //but wait for active transactions to complete
        uts.shutdown ( false );
        System.out.println("UserTransactionService shutdown completed: " + uts);
ps123 Send private email
Tuesday, June 18, 2013
 
 
Hi,

These changes I mentioned are not in 3.6 but in later releases. So you would have to upgrade to do that, unless you want to keep using 3.6 - in which case we might work something out but you would have to purchase our services.

I recommend trying to upgrade if you can...

HTH
Guy Pardon Send private email
Tuesday, June 18, 2013
 
 
Hi Guy,

Thank you for your response. We would check if upgrading the version helps resolving the issue.

One more thing that we found is that we switched to UserTransactionServiceImp to start the transaction. However the init call is taking a long time (5+ minutes) to complete. This is delaying our tomcat startup. Is this an expected behaviour? or there is a way to reduce this delay?
ps123 Send private email
Wednesday, June 19, 2013
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics