Bonjour Tout le monde,
Voilé je suis débutante avec scheduler et mon problème est le suivant:
j'aimerai scheduler un batch et surtout pouvoir traiter la politique de reprise, c'est à dire quand le job echou pouvoir relancer ce dernier autant de fois qui lui est permi, et pour ce faire j'ai lu des cours qui conseillé d'introduire un jobListener chose que j'ai faite mais sa n'a rien donné.
Voici ce que j'ai fait:
Tout d'abord j'ai introduit cette ligne dans le fichier xml de scheduler:
ensuite j'ai créer la callse du joblistener qui est la suivante:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <!-- *************************************************************** --> <!-- Declare a job listener that will take care of job retries, etc. --> <!-- *************************************************************** --> <bean id="myJobListener" class="org.quartz.JobListener"> <property name="name" value="myJobListener"/> <property name="jobDetail" ref="myJobListener"></property> </bean>
mais celà n'a pas marché et sa me génère celà:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 package com.scheduler.listener; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.quartz.JobListener; import org.springframework.batch.core.JobExecution; public class UnJobListener implements JobListener { public static final String LISTENER_NAME = "dummyJobListenerName"; public UnJobListener() { // TODO Auto-generated constructor stub } @Override public String getName() { // TODO Auto-generated method stub return LISTENER_NAME; } @Override // Run this if job is about to be executed. public void jobToBeExecuted(JobExecutionContext context) { // TODO Auto-generated method stub String jobName = context.getJobDetail().getKey().toString(); System.out.println("jobToBeExecuted"); System.out.println("Job : " + jobName + " is going to start..."); //JobDetail jobDetail = context.getJobDetail(); // MyJobDetail myJobDetail = (MyJobDetail) jobDetail; // jobDetail.getJobDataMap().put("MessageAdded", myJobDetail.getMyMessage()); } @Override public void jobExecutionVetoed(JobExecutionContext context) { // TODO Auto-generated method stub System.out.println("jobExecutionVetoed"); } @Override public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) { // TODO Auto-generated method stub System.out.println("jobWasExecuted"); String jobName = context.getJobDetail().getKey().toString(); System.out.println("Job : " + jobName + " is finished..."); if (!jobException.getMessage().equals("")) { System.out.println("Exception thrown by: " + jobName + " Exception: " + jobException.getMessage()); } } }
voilà si quelqu'un sait comment faire, a une idée ou autre sa m'aiderai énormément, s'il vous plait j'en ai besoin.INFO: Closing JPA EntityManagerFactory for persistence unit 'NCAKernel'
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myJobListener' defined in class path resource [schedulerAppContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.quartz.JobListener]: Specified class is an interface
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:997)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:943)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.prosodie.nca.scheduler.StandaloneScheduler.main(StandaloneScheduler.java:46)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.quartz.JobListener]: Specified class is an interface
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:56)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:990)
... 13 more
Merci à vous
Partager