• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A sample application/ example for Scheduler / Scheduling using Quartz way in Spring.

 
shibaram sahoo
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a sample application/ example for Scheduler / Scheduling using Quartz way in Spring. But I am not able to get the desired output.. the scheduler actually not getting called..

I also refered James Goodwill's A_simple_quartz_spring_example. But there inside the main method he have used some code like this as below..



I didnt get, what thisLookupFactory.getInstance(); method is doing and how to configure that.


Below are my setup and codes..

The Package Structure and Jars I have used is:



And below are the actual files i have used:

1. My Spring config file named (sched.xml) is:



2. Interface IMyJob.java




3. MyJobImpl.java




4. MyJobHandler.java



5. ExampleJob.java



6. my Main Execution Class named DoMyJobApp.java




Currently Output I am getting is:


Before Scheduler starts....

Gettting bean...
From MyJobImpl:: Have a great day !!

After Scheduler starts....


Problem i am facing is that Scheduler is neither executing the executeInternal() method from MyJobHandler class (as it should due to org.springframework.scheduling.quartz.JobDetailBean as set in sched.xml) nor its executing doForMe() from ExampleJob class (as it should due to org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean as set in sched.xml).

Please suggest me what configurations need to change.. and how exactly to load the config file and make the Scheduler run successfully.
[ September 04, 2007: Message edited by: shibaram sahoo ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Several problems :
1. In MyJobHandler, you have to rename the setMyJob method to setJob, because you have use "job" as an entry name of jobDataAsMap in sched.xml

2. You are not setting triggers correctly. You must configure the scheduler the following way :


3. You are using a BeanFactory. BeanFactory does not instanciate beans automatically, so the scheduler will never be instanciated. You have to use an ApplicationContext instead.


About LookupFactory.getInstance(), I have no idea what this is.
 
shibaram sahoo
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Christophe .

The points you have mentioned in points #1 and #2, are actually my faults. That i mistakenly did. But now I rectified those.

But Actually I had tried the Point#3 way before.. of loading the config file named "sched.xml". But was getting some exceptions.

Also I tried again the way You said here..
But i am getting exceptions as below:



Now do i need to add any jar related to org.apache.commons.collections.SetUtils..


THanks again for a warm response.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now do i need to add any jar related to org.apache.commons.collections.SetUtils..

Yes, you've got it right. You need Jakarta's Commons Collections library. If you have downloaded Spring with all dependencies, you can find it in the "lib/jakarta-commons" folder, named commons-collections.jar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic