I have several tasks that needs to run periodically as part of an overall web application solution... some every few minutes and some once a day. I know it's technically not a requirement that it run in a web container. But it needs all off the resources and database connections, etc just like the rest of the web app. I currently have a servlet that starts a timer in the servlet init:
aTimer = new Timer( true ); aTimer.scheduleAtFixedRate( new MyTimerTask(), getFirstTime(), getPeriod() ); The timer task has a run method that (as far as I know) runs and exits. This has all worked fine pre TC7. But now I'm getting this error message: A web application appears to have started a TimerThread named [Timer-114] via the java.util.Timer API but has failed to stop it. To prevent a memory leak, the timer (and hence the associated thread) has been forcibly cancelled. So.... is what I'm doing forbidden in official web container architecture? (And now TC 7 has started enforcing the rules?) Or is what I'm doing ok and just somehow my timer task is getting caught in a loop a few times and TC is just stopping it for that reason? What are my options? Is there a 'right' way to have a servlet run a task periodically in a web app? (sample code anywhere?) I know I can set up a standalone command line java app to do this one little task. But then I'd be stuck with a separate distribution file requiring setup, configuration, and management outside of a WAR file for what in actuality is one self-contained application. I will forego J2EE purity at this point if that's what's required and even risk the memory leak. I just need to get this back running again. If it's just a case of TC 7 now enforcing a rule, is there any way to tell TC 7 to NOT do me these favors of stopping all timer threads? Please advise.... Thanks. Jerry
