This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in Timeout method after 5 minutes

 
Ankit Garg
Sheriff
Posts: 9529
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Ankit Garg
Sheriff
Posts: 9529
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic