Announcement Announcement Module
Collapse
No announcement yet.
CronTriggerBean - Re-execute on error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • CronTriggerBean - Re-execute on error

    Hey,

    I am using CronTriggerBean to execute a process on a specific hour.
    I have two issues to solve and hope Spring has built in support:

    1) If the process failed i want to repeat it executing after 10 minutes and limit the number of repeats

    2) If the server was down on the execution time i want the process to execute as soon as the server is up again.


    Does Spring has any built in support for any of this issue? Below is my current applicationContext xml

    Code:
    <bean id="fxRatesFetcherJobDetail"
    		class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    		<property name="targetObject" ref="currencyExchangeRateFetcher" />
    		<property name="targetMethod" value="execute" />
    		<property name="concurrent" value="false" />
    	</bean>
    	
    	<bean id="fxRatesFetcherTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
        	<property name="jobDetail" ref="fxRatesFetcherJobDetail" />
        	<property name="cronExpression"
    			value="${com.outbrain.pcengine.currency.exchange_rates_fetcher_cron_expression}" />
    		<property name=""/>
      	</bean>
      	
    	<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="fxRatesFetcherTrigger" />
            </list>
        </property>
        <property name="autoStartup" value="${com.outbrain.pcengine.run.scheduled.tasks}"/>
      	</bean>

  • #2
    hi,

    I am try to execute a simple cron trigger using spring,but shows some error,i am using "quartz-1.6.0.jar"

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    javax.servlet.ServletException: Servlet.init() for servlet jewellery threw exception
    org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:104)
    org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:261)
    org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:844)
    org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:581)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:447)
    java.lang.Thread.run(Thread.java:662)

    root cause

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'exampleJob' defined in ServletContext resource [/WEB-INF/jewellery-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.springframework.scheduling.quartz.JobDetailBea n]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/collections/SetUtils
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:442)
    org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 45)
    org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:141)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:242)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:156)
    org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:290)
    org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:348)
    org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:156)
    org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:3 08)
    org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:252 )
    org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:221)
    org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:115)
    javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
    org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:104)
    org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:261)
    org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:844)
    org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:581)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:447)
    java.lang.Thread.run(Thread.java:662)

    root cause

    org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.springframework.scheduling.quartz.JobDetailBea n]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/collections/SetUtils
    org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:97)
    org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:59)
    org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:52)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateBean(Abstrac tAutowireCapableBeanFactory.java:639)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:625)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
    org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 45)
    org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:141)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:242)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:156)
    org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:290)
    org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:348)
    org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:156)
    org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:3 08)
    org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:252 )
    org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:221)
    org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:115)
    javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
    org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:104)
    org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:261)
    org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:844)
    org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:581)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:447)
    java.lang.Thread.run(Thread.java:662)

    root cause

    java.lang.NoClassDefFoundError: org/apache/commons/collections/SetUtils
    org.quartz.JobDetail.<init>(JobDetail.java:85)
    org.springframework.scheduling.quartz.JobDetailBea n.<init>(JobDetailBean.java:45)
    sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
    sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
    java.lang.reflect.Constructor.newInstance(Construc tor.java:513)
    org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:82)
    org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:59)
    org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:52)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateBean(Abstrac tAutowireCapableBeanFactory.java:639)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:625)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
    org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 45)
    org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:141)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:242)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:156)
    org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:290)
    org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:348)
    org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:156)
    org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:3 08)
    org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:252 )
    org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:221)
    org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:115)
    javax.servlet.GenericServlet.init(GenericServlet.j ava:212)
    org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:104)
    org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:261)
    org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:844)
    org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:581)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:447)
    java.lang.Thread.run(Thread.java:662)

    root cause

    java.lang.ClassNotFoundException: org.apache.commons.collections.SetUtils

    Please any one help!

    thanks,
    Amulraj

    Comment

    Working...
    X