• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

use cron in spring 2.5

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

<?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
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
angad jha
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<!-- 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
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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


 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic