spring/quartz probléme du contexte
Bonjour j'essaye d'exécuter un job qui me permet d'envoyer un mail
voila la configuration spring/quartz
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
<!-- ************ Quartz************ -->
<bean id="mailJobBean" class="com.test.locataire.bean.MailJobBean" >
<property name="mailService" ref="mailService"/>
</bean>
<bean id="monJobPojoJobDetail"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="mailJobBean" />
<property name="targetMethod" value="execute" />
</bean>
<bean id="monJobPojoCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="monJobPojoJobDetail" />
<property name="cronExpression" value="0/59 * * * * ?" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="monJobPojoCronTrigger"/>
</list>
</property>
</bean> |
et voila mon job
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
public class MailJobBean {
;
private MailService mailService;
private InternetAddress Adress;
private AdCollaborateur colab;
private LoginBean loginBean;
public MailService getMailService() {
return mailService;
}
public void setMailService(MailService mailService) {
this.mailService = mailService;
}
public InternetAddress getAdress() {
return Adress;
}
public void setAdress(InternetAddress Adress) {
this.Adress = Adress;
}
public void execute(JobExecutionContext context
) throws AddressException, MessagingException {
ELContext elContext = FacesContext.getCurrentInstance().getELContext();
loginBean = (LoginBean) FacesContext.getCurrentInstance().
getApplication().getELResolver().
getValue(elContext, null, "LoginBean");
try {
Adress = new InternetAddress("test@mail.fr", "mahdi");
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(MailJobBean.class.getName()).log(Level.SEVERE, null, ex);
}
try {
mailService.sendMail(loginBean.getCollab().getCollEmail(),Adress, "test", "salut", null);
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(MailJobBean.class.getName()).log(Level.SEVERE, null, ex);} |
bien sur mon job est déclaré dans le facesconfig
mon probléme c'est que j(ai toujours une erreur avec le contexte
aused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.test.locataire.bean.MailJobBean]: Constructor threw exception; nested exception is java.lang.NullPointerException
l'erreur toujours ce pointe sur ELContext elContext = FacesContext.getCurrentInstance().getELContext();