Announcement Announcement Module
Collapse
No announcement yet.
BeanFactory is null ? Help me plzzzzzz Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • BeanFactory is null ? Help me plzzzzzz

    Hey my benaFactory is null

    public class EmailJob extends QuartzJobBean implements StatefulJob {

    public ApplicationContext applicationContext;

    public void setApplicationContext(ApplicationContext appContext) {
    this.applicationContext = appContext;
    }

    public ApplicationContext getApplicationContext() {
    return applicationContext;
    }


    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {

    SchedulerContext schedulerContext = context.getScheduler().getContext();


    BeanFactory beanFactory = (BeanFactory)schedulerContext.get("applicationCont ext");





    }


    Here is my applicationContext.xml

    <beans>

    <bean id="emailJob" class="org.springframework.scheduling.quartz.JobDe tailBean">
    <property name="jobClass" value="com.graysail.caj.actions.EmailJob"/>
    <property name="businessMgr"><ref bean="businessMgr"/></property>
    </bean>

    <bean id="emailTrigger" class="org.springframework.scheduling.quartz.Simpl eTriggerBean">
    <property name="jobDetail" ref="emailJob"/>
    <property name="repeatInterval" value="30000"/>
    </bean>

    <bean class="org.springframework.scheduling.quartz.Sched ulerFactoryBean">
    <property name="triggers"> <ref bean="emailTrigger" /> </property>
    <property name="applicationContextSchedulerContextKey"><valu e>applicationContext</value></property>

    </bean>



    </beans>


    please can some one tell me why beanFactory is null ?

    am i doing it right

    Thanks

    Rajesh Danala

  • #2
    youe EmailJob bean needs to implement the ApplicationContextAware interface so that the application context knows to inject itself into the EmailJob bean when you request it.

    Comment

    Working...
    X