Falae povo…
Problema é o seguinte…
Estou fazendo um scheduler com o quatz pra fazer um backup do meu bd diariamente, porém, estou com esse problema:
[quote]org.quartz.ObjectAlreadyExistsException: Unable to store Job with name: ‘JDBC Connection’ and group: ‘mysql’, because one already exists with this identification.
at org.quartz.simpl.RAMJobStore.storeJob(RAMJobStore.java:221)
at org.quartz.simpl.RAMJobStore.storeJobAndTrigger(RAMJobStore.java:193)
at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:801)
at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:243)
at br.com.promogrape.java.scheduler.ConnectionScheduler.<init>(ConnectionScheduler.java:22)
at br.com.promogrape.java.scheduler.ConnectionScheduler.contextInitialized(ConnectionScheduler.java:33)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
[/quote]
Minhas classes estão assim:
[code]public class ConnectionScheduler implements ServletContextListener {
public ConnectionScheduler() throws Exception {
SchedulerFactory sf = new StdSchedulerFactory();
Scheduler sche = sf.getScheduler();
sche.start();
JobDetail jDetail = new JobDetail("JDBC Connection", "mysql",
ConnectionJob.class);
CronTrigger crTrigger = new CronTrigger("cronTrigger", "mysql",
"0 0 23 * * ? *");
sche.scheduleJob(jDetail, crTrigger);
}
@Override
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void contextInitialized(ServletContextEvent arg0) {
try {
new ConnectionScheduler();
} catch (Exception e) {
e.printStackTrace();
}
}
}[/code]
[code]public class ConnectionJob implements Job {
private MySQLDumper dumper;
public ConnectionJob() {
dumper = new MySQLDumper();
}
public void execute(JobExecutionContext context)
throws JobExecutionException {
System.out.println("Job name:" + context.getJobDetail().getName());
System.out.println("Group name:" + context.getJobDetail().getGroup());
System.out.println("Trigger name:" + context.getTrigger().getName());
System.out.println("Firing Time:" + context.getFireTime());
try {
dumper.export();
} catch (Exception s) {
s.printStackTrace();
System.exit(0);
}
}
}[/code]
Na exception diz que o agendamento já existe, mas não entendo o pq se estou iniciando a aplicação.
Alguma idéia?
Abraço