Take the 2-minute tour ×

good people. i'm trying to use quartz with spring in a very simple project managed by maven.So in the module in which the mycron job class is i included a java main class to it just to see the job output some text and new date. here is my spring config:

    <bean id="projUpdater" class="org.springframework.scheduling.quartz.JobDetailBean">
        <property name="jobClass" value="com.myproject.utilscheduling.quartz.ProjUpdaterCronImpl" />
<!---End of Jobs-->
    <bean id="regularUpdateTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail" ref="projUpdater"/>
        <property name="cronExpression" value="30 1 * * * ?"/>
<!--End ofTriggers-->
<!--Scheduler Factory-->
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="triggers">
            <ref bean="regularUpdateTrigger"/>
<!--End of Scheduler Factory-->
<!--End of Scheduling-->

and here is the job class

public class ProjUpdaterCronImpl extends QuartzJobBean {

public ProjUpdaterCronImpl() {

protected void executeInternal (JobExecutionContext ctx) throws JobExecutionException {
	System.out.println("[JOB] " + new Date() + "hello");


here is main class

public class NewMain {

 * @param args the command line arguments
 public static void main(String[] args) {
    System.out.println("starting job");


so in my understanding the job will be started after 1mn30s and posted on the console.I'm wrong.i faced couple or errors that i solve so i can safely assume that there is no error in in spring configuration file since there is none when building and running.So what did i do wrong or what did i forget to do?

second concern since i'm forcing myself to go the test driven way how will i possibly test a the cron job class? thanks for reading

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Your cron expression


actually configures the trigger to fire once every hour at 1 minute 30 seconds after the hour.

Zoidberg's suggestion to use MethodInvokingJobDetailFactoryBean allows you to code your cron job as a POJO, making it easy to test.

share|improve this answer
mmmh that's tricky. 60 0 0 * * ? will do every minute? –  black sensei Sep 23 '09 at 17:48
No, "0 * * * * ?" fires every minute. Check out the documentation at opensymphony.com/quartz/wikidocs/CronTriggers%20Tutorial.html –  Chin Huang Sep 23 '09 at 18:04
thanks dude i have to really sit down and read this stuffs thanks man –  black sensei Sep 23 '09 at 18:55
add comment

Try this for your job bean.

<bean id="projUpdater" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject" ref="registeredObject" />
        <property name="targetMethod" value="methodNameInObject" />

Where your registeredObject is a bean registered in the spring config somewhere. And the method is a method that exists in that object.

share|improve this answer
i'll try your suggestion i've been seeing this form on the net a lot .by the way how to get what i did work actually unless i won't know how to use it that way.i mean for a beginner like me it's key to know what i did wrong.thanks –  black sensei Sep 23 '09 at 19:42
add comment

Your Answer


