Announcement Announcement Module
No announcement yet.
Container not setting ApplicationEventPublisher Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Container not setting ApplicationEventPublisher


    I have a class which implements ApplicationEventPublisherAware and is supposed to periodically publish an ApplicationEvent.

    The problem is my application context does not appear to be automatically setting the ApplicationEventPublisher in this object as it should.

    Below is the bean configuration which should give you an idea as to what im trying to do.

    Any help greatly appreciated!

    <!-- System Status Heartbeat -->
    <bean name="heartBeatJob" class="org.springframework.scheduling.quartz.JobDe tailBean">
    <property name="jobClass" value="com.utilities.heartbeat.HeartBeatTask" />

    <bean id="heartBeatTrigger" class="org.springframework.scheduling.quartz.Simpl eTriggerBean">
    <!-- see the example of method invoking job above -->
    <property name="jobDetail" ref="heartBeatJob" />

    <!-- 10 seconds -->
    <property name="startDelay" value="5000" />

    <!-- repeat every 50 seconds -->
    <property name="repeatInterval" value="1000" />

    <bean id="scheduler" class="org.springframework.scheduling.quartz.Sched ulerFactoryBean">
    <property name="triggers">
    <ref bean="heartBeatTrigger" />

    <bean id="heartBeatForwarder" class="com.utilities.HeartBeat" />

  • #2
    Which class implements the ApplicationEventPublisherAware interface? Is it possible to see the code for what you are doing? It always helps to use [code] [ /code] tags as well!
    Last edited by karldmoore; Aug 29th, 2007, 11:08 AM.


    • #3
      Please read the APIDocs for the JobDetailBean:
      In the setApplicationContextJobDataKey docs the following is stated:
      Note that BeanFactory callback interfaces like ApplicationContextAware are not automatically applied to Quartz Job instances, because Quartz itself is responsible for the lifecycle of its Jobs.
      So, configure this property (applicationContextJobDataKey) and set it to "applicationEventPublisher": I think that will do the trick, since the ApplicationContext extends ApplicationEventPublisher. Like the API docs state, set it on the SchedulerContext instead if you're using a persistent job that stores its state in a database.