How to cancel Timers permanently?
615547Jul 18 2011 — edited Oct 4 2011We 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();
}