Beleza galera?
Estou seguindo um exemplo de uso de quartz com spring nesse site: http://www.springframework.org/docs/reference/scheduling.html
Criei uma aplicação standalone que precisa imprimir na tela uma determinada hora do dia a palavra Hello Spring World!. Quando executo a aplicação que fiz dá o seguinte erro:
Exception in thread "Main Thread" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'exampleJob' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoSuchMethodError: orderedSet
java.lang.NoSuchMethodError: orderedSet
A pergunta é: Como devo implementar esse método? Ele tem que ser void? Qual o seu conteudo?
o meu código está assim:
Classe main
import job.Exemplo;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Agendamento {
private static ApplicationContext appContext;
/**
* Inicializa o contexto da aplicação spring
* @author Sergio Stateri Jr
* @return ApplicationContext
*/
public static ApplicationContext getApplicationContext() {
if ( appContext == null ) {
appContext = new ClassPathXmlApplicationContext("applicationContext.xml");
}
return appContext;
}
/**
* @param args
*/
public static void main(String[] args) {
Exemplo job = (Exemplo)Agendamento.getApplicationContext().getBean("exampleJob");
}
}
A classe de negócio
package job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;
public class Exemplo extends QuartzJobBean{
private int timeout;
/**
* Setter called after the ExampleJob is instantiated
* with the value from the JobDetailBean (5)
*/
public void setTimeout(int timeout) {
this.timeout = timeout;
}
@Override
protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException {
System.out.println("Hello Spring World! ");
}
}
e o aplicationContext está assim:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE beans PUBLIC
"-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="no" default-lazy-init="false" default-dependency-check="none">
<bean name="exampleJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="job.Exemplo" />
<property name="jobDataAsMap">
<map>
<entry key="timeout" value="5" />
</map>
</property>
</bean>
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="exampleJob" />
<!-- run every morning at 6 AM -->
<property name="cronExpression" value="0 0 12 * * ?" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTrigger" />
</list>
</property>
</bean>
</beans>
Agradeço qualquer ajuda!