Two Laptop Bag*
The moose likes Spring and the fly likes use cron in spring 2.5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "use cron in spring 2.5" Watch "use cron in spring 2.5" New topic
Author

use cron in spring 2.5

angad jha
Greenhorn

Joined: Dec 26, 2013
Posts: 5

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd">

<!-- Spring's scheduling method -->
<task:scheduled-tasks scheduler="taskScheduler">
<task:scheduled ref="cronService" method="createCSVMail" cron="0 0 9 ? * THU,FRI,SAT"/>
</task:scheduled-tasks>

<!-- The bean that does the actual work by this class , and these class include work method-->
<bean id="cronService" class="com.java.db.MessageSheduler" />

<!-- Defines a ThreadPoolTaskScheduler instance with configurable pool size. -->
<task:scheduler id="taskScheduler" pool-size="1"/>

</beans>

I am using these expression for automatic mail but createCSVMail is not calling.Could you guide me.

thanks
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1646
    
    7

Your topic says Spring 2.5. The task namespace was not added until 3.0. I see you are still importing the 3.0 namespace in your XML though. If you are using Spring 2.5 libs, I suggest you upgrade if you can, that is a very old version of Spring.


[How To Ask Questions][Read before you PM me]
angad jha
Greenhorn

Joined: Dec 26, 2013
Posts: 5
<!-- Scheduling config -->
<import resource="scheduling-context.xml" />

I have already added these line in my spring 2.5 dispatcher-servlet.xml file .This is working on my local server but not on live server like if i want to schedule for every 2 mins it is working on localhost but the same is not working for a particular day like if want it to run on a particular day like for example thursday or friday its not working neither on localhost nor on liveserver.
exp:<b>cron="0 0 9 ? * THU,FRI,SAT" </b>could you please tell me the problem if their is any with this line. For the full code please refer above

P.S :-- I have already imported all spring 3 jar file pom.xml

Thanks
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1646
    
    7

angad jha wrote: <!-- Scheduling config -->
<import resource="scheduling-context.xml" />

I have already added these line in my spring 2.5 dispatcher-servlet.xml file .

Thanks


Why do you keep saying 2.5 if you are using Spring 3. Which are you using Spring 3 or Spring 2.5? If you are using Spring 2.5 that is a problem. If you are using Spring 3 are you defining the scheduler in the root context? It belongs there not in the servlet context.

Is com.java.db.MessageSheduler the fully qualified path to the correct class? if so Scheduler is spelled wrong. Also does it contain a method called createCSVMail?

Also try changing your cron to fire every 5 minutes so you can verify everything else works and then try to get fancier with the cron


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: use cron in spring 2.5
 
Similar Threads
Injection of autowired dependencies failed
Simple Spring Batch
Spring JDBC Problem getting log messages
can we notify if scheduler task not running at given time intervals
mbean exporting with spring-jmx using annotations