I have been starting quartz jobs in a servlet but this has been causing problems as the servlet is getting init'ed twice. I know starting thread/processes in a servlet is not recomended in the J2EE spec.
Is there a better way to do this? Something that does not go against the spec? The docs seem to say do it in a servlet but we really dont want to do this.
tomcat 6.0.20 / JDK 1.7
So the servlet gets made twice and 2 jobs get started.
I just hacked it for now and when the context is ROOT I don't start the job.
Paul Clapham wrote:Even so you might be better advised to write a ServletContextListener and start the Quartz job in its contextInitialized method. That way you won't bump into cases later where the container decides for some reason that it needs two instances of your servlet.
I'll probably do that actually, seems a bit shocking that Quartz document this as standard pratice.
I once started a big fight in a company I was consulting for, they had got an outside consultancy to write a large trading platform and I was asked to review it, when I found out the processes were all started in a servlet I told the client this was strictly not allowed then walked away as the contracts and lawyers got brought out.