wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Possible to run an EJB3 timer without transaction? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Possible to run an EJB3 timer without transaction?" Watch "Possible to run an EJB3 timer without transaction?" New topic
Author

Possible to run an EJB3 timer without transaction?

Steve Sinai
Greenhorn

Joined: Aug 21, 2004
Posts: 25
Is there a way to run an EJB3 timer without it being inside a transaction?

Sometimes the methods run by the timer throw exceptions, and I'd like to be able to update a database with a failed flag if that happens. But the EJBTransactionRolledbackException that gets thrown prevents me from doing this.

Thanks.
Meiyappan Kannappa
Greenhorn

Joined: Sep 15, 2008
Posts: 10
I hope you can disable the transaction by setting the transaction attribute to Never or Not supported . But I havent tried of this scenario.


Warm Regards
Steve Sinai
Greenhorn

Joined: Aug 21, 2004
Posts: 25
I was able to solve the problem by not throwing Timer exceptions up to a common exception handling method. Instead I caught them and dealt with them in the method in which they were caught.

It was turning out that if I threw an exception up the method chain, EJB would automatically embed it in some kind of transaction exception, which meant I couldn't write something to the database notifying people that an exception had occurred. If I didn't throw the exception, then there was no transaction exception involved.
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 860

Thanks for sharing Steve, interesting...

WP
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Possible to run an EJB3 timer without transaction?
 
Similar Threads
How to i invoke a method every 24 hours
Integrating hibernate with spring
Transaction attributes
Timers
Invocation of a TimerService