Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to cancel Timers permanently?

615547Jul 18 2011 — edited Oct 4 2011
We are running our application in Weblogic 10.3. We have an EJB timer that runs all the time and kicks off a piece of code every x minutes. The problem is when an Exception happens and we cancel the timer the timer gets cancelled but some references still remain in the memory which will cause issues when the next time we run the application. (A new timer is then created but the old timer seems to be still there.)

The way we cancel the timer is as follows:

Collection timers = ctx.getTimerService().getTimers();
Collection<Timer> list = timers;
Iterator<Timer> it = list.iterator();

while(it.hasNext){
timer = it.next();
timer.cancel();
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 1 2011
Added on Jul 18 2011
4 comments
377 views