Joe Sango's Blog

Friday, February 25, 2005

Should we start running?

I have recently implemented job sheduling inside a client's web service based J2EE app using Quartz. The client app utilises the Spring framework using Tomcat and Quartz fits in a treat. I must admit, it was'nt a trivial process getting it up and running but quite nifty once implemented.
Anyone thinking of using Quartz with Spring, definitely check out the Spring API and the Quartz tutorial.
The only thing that the doco did'nt tell me was how to kick off my scheduling job once configured. Prepare to tune out............
I used a servlet that executes on Tomcat startup that creates a reference to a SingletonBeanFactoryLocator which simply calls its only method useBeanFactory(), passing it the qualified name of the relevant bean which you setup in Spring's config files. Confused? Well there's more. Once you get a reference to the specified bean, Spring will automatically find and load all the beans you have configured including the schedule bean hence, starting the sheduler.
...............and we are back again.........


  • a) Could you kindly share this "kick-off" code here?

    b) So suffice to say no need to wake-up QuartInitializer servlet via entry in web.xml. Correct?

    By Anonymous neal ravindran, at 4:46 AM  

  • Unfortunately, I have not got access to that code anymore otherwise I would gladly share it. There is a bunch of stuff on the web about it.
    Spring automates all that stuff for you so you dont need to worry about that.

    By Blogger Joe Sango, at 10:13 AM  

  • I use tomcat 5.0 and have nothing in my web.xml mentioning a word about spring's applicationContext.xml (but it is placed in WEB-INF and I am under the impression the context loader will find it). So from what you are saying if I have the cronTrigger bean set up in applicationContext.xml and on start of tomcat spring will load the bean and do the necessary to run the cron at prescribed time. Correct?

    But the cron job does not run...:(
    even though i have explicitly said singleton="true" for the cron trigger bean

    By Anonymous neal ravindran, at 12:36 AM  

Post a Comment

<< Home