Atomikos Forum

Timeout problems

Hi. I have a problem setting transaction timeouts.

I have this in my jta.properties:

com.atomikos.icatch.max_timeout=2147483647

I'm using Tomcat 5.5.26, and in my server.xml I have this listener declared:

<Listener className="com.test.AtomikosLifecycleListener" />

Which has this code in it to create the com.atomikos.icatch.jta.UserTransactionManager instance:

####################
if (Lifecycle.START_EVENT.equals(event.getType())) {
    if (utm == null) {
        utm = new UserTransactionManager();
    utm.setTransactionTimeout(Integer.MAX_VALUE);
    }
} else if (Lifecycle.STOP_EVENT.equals(event.getType())) {
    utm.close();
}
####################

These two things should set a high transaction timeout, but whenever I debug my code inside a transaction, if I take just a few seconds (under a minute), I always get this error:

####################
java.lang.IllegalStateException: This method needs a transaction for the calling thread and none exists.
Possible causes: either you didn't start a transaction,
it rolledback due to timeout, or it was committed already.
ACTIONS: You can try one of the following:
1. Make sure you started a transaction for the thread.
2. Make sure you didn't terminate it yet.
3. Increase the transaction timeout to avoid automatic rollback of long transactions; check http://www.atomikos.org/forums/viewtopic.php?t=1259 for how to do this.
####################

As you can see, I'm doing the things explained in the URL above. What am I  missing?

Thanks in advance.
Diego Manilla Suárez Send private email
Wednesday, October 08, 2008
 
 
Hi,

Calling utm.setTransactionTimeout(Integer.MAX_VALUE) only sets the timeout for future transactions that will execute on the current thread. As silly as this may sound, this is what the JTA spec says how it must be.

The correct way to set a timeout is to always call setTransactionTimeout() just before calling begin().
Ludovic Orban Send private email
Wednesday, October 08, 2008
 
 
Hi, thanks for your reply.

I have a little doubt. I'm using Hibernate 2 and I have this property set:

hibernate.transaction.manager_lookup_class=com.atomikos.icatch.jta.hibernate.TransactionManagerLookup

The thing is, this class returns a new instance of UserTransactionManager. Should I extend this class to set the timeout, too, or the timeout set on my Tomcat's lifecycle listener prevails over this? Are they mutually exclusive?

Thanks again.
Diego Manilla Suárez Send private email
Wednesday, October 08, 2008
 
 
We would have to see a tm.out in DEBUG mode to know more.
Guy Pardon Send private email
Thursday, October 09, 2008
 
 
I can't for the life of me get a higher timeout. Now, I've modified the class configured in hibernate.transaction.manager_lookup_class to set a higher timeout, and commented the Tomcat's lifecycle listener, with no luck.

As for the tm.out log, here are the relevant parts (I hope):

08-10-09 10:25:47,286 [main] USING com.atomikos.icatch.max_timeout = 2147483647
.
.
.
08-10-09 10:29:39,424 [Atomikos:7] Rollback of timedout ACTIVE coordinator !
08-10-09 10:29:39,424 [Atomikos:7] Coordinator 192.168.1.24.tm0000200001 entering state: ABORTING
08-10-09 10:29:39,424 [Atomikos:7] Coordinator 192.168.1.24.tm0000200001 entered state: ABORTING
08-10-09 10:29:39,424 [Atomikos:7] Coordinator 192.168.1.24.tm0000200001 entering state: TERMINATED
08-10-09 10:29:39,424 [Atomikos:7] Coordinator 192.168.1.24.tm0000200001 : stopping timer...
08-10-09 10:29:39,424 [Atomikos:7] Coordinator 192.168.1.24.tm0000200001 : disposing statehandler TERMINATED...
08-10-09 10:29:39,424 [Atomikos:7] Coordinator 192.168.1.24.tm0000200001 : disposed.
08-10-09 10:29:39,424 [Atomikos:7] rollback() done of transaction 192.168.1.24.tm0000200001
08-10-09 10:29:39,424 [Atomikos:7] Coordinator 192.168.1.24.tm0000200001 entered state: TERMINATED
08-10-09 10:29:46,924 [Atomikos:0] ConnectionPool: trying to shrink pool
08-10-09 10:29:46,924 [Atomikos:0] ConnectionPool: reaping old connections
Diego Manilla Suárez Send private email
Thursday, October 09, 2008
 
 
OK, problem solved. My custom class was setting a timeout of Integer.MAX_VALUE on the TransactionManager instance, but this value, as it is specified in seconds, was beign multiplied by 1000 later on, and so the value was overflowing.

Thanks for your help.
Diego Manilla Suárez Send private email
Thursday, October 09, 2008
 
 

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

Other recent topics Other recent topics