Hi,
The advices given above are good. If you make this job triggered by a
servlet, then an attacker can use it to easily bring down your system
with excessive load.

You also have problems of clean shutdown. The thread pool that you
start needs to have blocking shutdown with some context listener, to
make sure that all jobs are finished when you undeploy or shut down
the server. This is not hard to do, but you should test it by making
sure a job finishes when you shut down. Just add a slow job that, and
kill the server.

Slow job:
public void run(){
System.out.println("Starting slow job");
try{
  Thread.sleep(60000); // 1 min
}catch(Throwable e){
  e.printStachTrace();// possible kill, watch out for this
}
System.out.println("Finished slow job");
}

Add this job to the pool, shut down the server, and look at the logs
for the messages. You should also see the server hanging until the job
is completed.

A simpler option would be to write a java class with a main method,
and run it from cron. We have a bunch of those. Not dependent on
tomcat, no security problems. You can have many tomcats with the same
configuration, something that would be more difficult with a scheduler
that is part of your app.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to