File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes A sample application/ example for Scheduler / Scheduling using Quartz way in Spring. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "A sample application/ example for Scheduler / Scheduling using Quartz way in Spring." Watch "A sample application/ example for Scheduler / Scheduling using Quartz way in Spring." New topic
Author

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

shibaram sahoo
Greenhorn

Joined: Sep 21, 2005
Posts: 17
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 ]

We can do it !!
http://letitsearch.googlepages.com/a.html
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

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.


[My Blog]
All roads lead to JavaRanch
shibaram sahoo
Greenhorn

Joined: Sep 21, 2005
Posts: 17
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A sample application/ example for Scheduler / Scheduling using Quartz way in Spring.