wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Exception in Timeout method after 5 minutes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Exception in Timeout method after 5 minutes" Watch "Exception in Timeout method after 5 minutes" New topic
Author

Exception in Timeout method after 5 minutes

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Hi ranchers,

I'm stuck in a problem. I have a timer service method, which does a long task. When it starts working, it gets a list of objects from the database using another EJB (which uses EntityManager to get the list). Now as the timeout method is doing its job, after 5 minutes I get this exception



Now I don't know if this exception is due to some sort of persistence of the timer service or the list that I got from the database. The code to get the list is simple



So I suppose this must not be the cause as the result list will not be managed when it is returned from this EJB method to the timer service method. So I'm guessing that this has to do something with persistence of the EJB but I'm not sure. I'm using jBoss AS 4.0.4 (patched for EJB 3). Any help would be appreciated...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

I've found the solution. I learned from this article that timers are created with their own transaction to be able to access entities. So that transaction was timed out after 5 minutes. So to solve that there were two solutions in front of me,

1. I use the @org.jboss.annotation.ejb.TransactionTimeout annotation to set the timeout to a longer value (which I think is only supported by jboss)

2. Use the @javax.ejb.TransactionAttribute annotation and use TransactionAttributeType.NEVER so that that timeout method doesn't get a transaction.

I used the second method as my timeout method didn't access entities directly from the database. I hope this might help other who get stuck like me ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception in Timeout method after 5 minutes