Announcement Announcement Module
Collapse
No announcement yet.
Quartz 2.1 & spring 3.1 - JobListener and TriggerListener issues Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quartz 2.1 & spring 3.1 - JobListener and TriggerListener issues

    Hello,

    I am getting the following exception while adding JobListener and TriggerListener to the SchedulerFactoryBean.

    Does anyone have an idea of what I am doing wrong in the configuration?

    Exception:
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jobScheduler' defined in URL [<<App_Location>>/WEB-INF/classes/scheduler-framework.xml]: Cannot resolve reference to bean 'scheduler' while setting bean property 'scheduler'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'scheduler' defined in URL [<<App_Location>>/WEB-INF/classes/scheduler-framework.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Expected Quartz API not present: java.lang.NoSuchMethodException: org.quartz.core.ListenerManagerImpl.addJobListener (org.quartz.JobListener)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:328)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:106)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1360)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1118)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 94)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:225)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:291 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:322)
    ... 62 more
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'scheduler' defined in URL [<<App_Location>>/WEB-INF/classes/scheduler-framework.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Expected Quartz API not present: java.lang.NoSuchMethodException: org.quartz.core.ListenerManagerImpl.addJobListener (org.quartz.JobListener)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1455)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 94)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:225)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:291 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:322)
    ... 72 more
    Caused by: java.lang.IllegalStateException: Expected Quartz API not present: java.lang.NoSuchMethodException: org.quartz.core.ListenerManagerImpl.addJobListener (org.quartz.JobListener)
    at org.springframework.scheduling.quartz.SchedulerAcc essor.registerListeners(SchedulerAccessor.java:518 )
    at org.springframework.scheduling.quartz.SchedulerFac toryBean.afterPropertiesSet(SchedulerFactoryBean.j ava:510)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1452)
    ... 79 more

    Configuration:
    <bean id="scheduler" class="org.springframework.scheduling.quartz.Sched ulerFactoryBean" lazy-init="false" destroy-method="destroy">
    <property name="taskExecutor" ref="taskExecutor"></property>
    <property name="dataSource" ref="schedulerDataSource" />
    <property name="schedulerName" value="SampleClusteredScheduler" />
    <property name="quartzProperties">
    <props>
    <prop key="org.quartz.jobStore.misfireThreshold">60000</prop>
    <prop key="org.quartz.jobStore.class">org.springframewor k.scheduling.quartz.LocalDataSourceJobStore</prop>
    <prop key="org.quartz.jobStore.tablePrefix">QRTZ_</prop>
    <prop key="org.quartz.jobStore.driverDelegateClass">org. quartz.impl.jdbcjobstore.StdJDBCDelegate</prop>
    <prop key="org.quartz.scheduler.instanceName">Sample_Sch eduler</prop>
    <prop key="org.quartz.scheduler.instanceId">AUTO</prop>
    <prop key="org.quartz.jobStore.selectWithLockSQL">SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?</prop>
    <prop key="org.quartz.jobStore.isClustered">true</prop>
    <prop key="org.quartz.jobStore.clusterCheckinInterval">2 0000</prop>
    </props>
    </property>
    <property name="globalJobListeners">
    <list>
    <ref local="schedulerJobListener" />
    </list>
    </property>
    <property name="schedulerListeners">
    <list>
    <ref local="schedulerListener" />
    </list>
    </property>
    <property name="globalTriggerListeners">
    <list>
    <ref local="schedulerTriggerListener" />
    </list>
    </property>
    </bean>

    <bean id="schedulerListener" class="com.sample.scheduler.listener.SchedulerList ener" />
    <bean id="schedulerJobListener" class="com.sample.scheduler.listener.SchedulerJobL istener" />
    <bean id="schedulerTriggerListener" class="com.sample.scheduler.listener.SchedulerTrig gerListener" />

    Thanks,
    Joshan

  • #2
    In Quarts 2.1 all listeners were moved to ListenerManager. Here is the code which I used to add the listeners

    ListenerManager listenerManager = schedulerManager.getScheduler().getListenerManager ();
    listenerManager.addJobListener(JobListener, new MatcherSupport());
    listenerManager.addTriggerListener(triggerListener , new MatcherSupport());
    listenerManager.addSchedulerListener(schedulerList ener);

    Note: Please make sure to remove the following lines from the xml

    <property name="globalJobListeners">
    <list>
    <ref local="schedulerJobListener" />
    </list>
    </property>
    <property name="schedulerListeners">
    <list>
    <ref local="schedulerListener" />
    </list>
    </property>
    <property name="globalTriggerListeners">
    <list>
    <ref local="schedulerTriggerListener" />
    </list>
    </property>
    Last edited by joshanjoe; Feb 9th, 2012, 12:34 PM.

    Comment


    • #3
      can it be done declaratively

      Is there a way to do that declaratively in the xml instead of programatically in the code? Regards

      Lucas Kuperman

      Comment

      Working...
      X