2

I created a timer in EJB 3.0 , weblogic 10.3, and when an exception occurs during the timeout method, this method is executed again several times, with the exception happening all the time. how can I disable this feature ?

Rich Benner
  • 7,873
  • 9
  • 33
  • 39
Leo
  • 1,829
  • 4
  • 27
  • 51
  • I think this link is solving your problem [http://stackoverflow.com/questions/2112190/how-to-stop-endless-ejb-3-timer](http://stackoverflow.com/questions/2112190/how-to-stop-endless-ejb-3-timer) – Alexander Petrov Jul 07 '16 at 16:49
  • @AlexanderPetrov It is not the same problem, the one in that question is due to persistence, the one Im having is because of retrying after exceptions. – Leo Jul 07 '16 at 17:20

1 Answers1

3

The current transaction is marked for rollback whenever a RuntimeException is propagated back through an EJB call.

EJB timers are transactional, so any RuntimeException thrown from an EJB call from the timer method or the timer method itself will cause a rollback.

Therefore, in order to prevent the timer machinery from retrying the timer, you must prevent any rollbacks in the call chain from the timer method by catching said RuntimeExceptions before they're thrown from any EJB calls or the timer method itself.

The same issue exists in message driven beans FWIW.

Steve C
  • 18,876
  • 5
  • 34
  • 37
  • Alternatively, EJB methods invoked from the Timer may be marked as isolated from the transaction ( `@RequiresNew` ) or throw only checked exceptions from EJB methods invoked by the Timer. A checked exception thrown by a timer-invoked EJB is disregarded by the container. – dan Oct 11 '17 at 19:13