Vraptor + quartz

blz …testando…

Ei cara, MUITO obrigado, funcionou aqui agora é so dar uma conferida na logica.

cara…vlw mesmo irado.

Legal cara! Fico feliz!

É interessante marcar o assunto do primeiro post com um [Resolvido]…

Boa pessoal, blz?
Desculpa reabrir o tópico, estou configurando o Quartz no meu projeto e já está rodando, o básico. Só que no meu caso eu tenho o requisito de permitir ao administrador do sistema, alterar a data/hora de execução do job via tela.

Alguma sugestão?

Vlw!

cancela o job que já existe e reagenda para um novo horário.

Blz, vou dar uma estudada como fazer isso.

Outra dúvida: como eu faço para “agendar” os métodos da minha controller?
Ou eu preciso de uma classe pra cada job?

vc está usando esse plugin?

[quote=Lucas Cavalcanti]vc está usando esse plugin?
https://github.com/wpivotto/vraptor-tasks[/quote]

Sim!

Dei um olhada no tópico “Tasks and Request Scope”. Mas não entendi muito bem.

Na classe do exemplo dado pelo Rafael Guerreiro a classe tem as seguintes “anotações”:
@ApplicationScoped
@Scheduled(cron = “* * * * * * *”)
public class Schedule implements Task {

e implementa o metodo execute();

Já no exemplo do github, a controller não implementa Task…

O que eu gostaria era ter uma controller com vários métodos com agendamentos diferentes.
Qual a melhor forma e como fazer? poderia me ajudar?

Na seção Tasks and RequestScope:

Galera, também estou com problemas para implementar o quartz junto com o Vraptor.

Depois de colocar os 3 jars na pasta lib está dando erro pra subir o projeto.

Eu apenas coloquei as jars na pasta lib, não mechi em nada do código.

O erro é este:


...
14-06-30 14:31:59,876 [INFO] org.springframework.beans.factory.support.DefaultListableBeanFactory - Overriding bean definition for bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor': replacing [Root bean: class [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Root bean: class [br.com.caelum.vraptor.ioc.spring.InjectionBeanPostProcessor]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
14-06-30 14:31:59,939 [INFO] org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@195de2f: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,defaultResourceTranslator,defaultRouter,defaultRoutes,objenesisInstanceCreator,defaultTypeNameExtractor,JSR303ValidatorFactory,pathAnnotationRoutesParser,defaultResourceNotFoundHandler,encodingHandlerFactory,interceptorListPriorToExecutionExtractor,defaultInterceptorHandlerFactory,defaultAcceptHeaderToFormat,cglibProxifier,messageInterpolatorFactory,topologicalSortedInterceptorRegistry,defaultRestDefaults,defaultMultipartConfig,hibernateProxyInitializer,paranamerNameProvider,defaultTypeFinder,defaultMethodNotAllowedHandler,javaEvaluator,defaultDeserializers,XStreamConverters.NullConverter,noRoutesConfiguration,defaultConverters,validatorFactoryCreator,stereotypeHandler,converterHandler,interceptorStereotypeHandler,deserializesHandler,stereotypedBeansRegistrar,defaultSpringLocator,ognlFacade,defaultHttpResult,defaultRepresentationResult,replicatorOutjector,defaultFormatResolver,defaultServletFileUploadCreator,defaultStatus,deserializingInterceptor,defaultRestHeadersHandler,defaultPathResolver,ognlParametersProvider,messageConverter,flashInterceptor,sessionFlashScope,defaultExceptionMapper,commonsUploadMultipartInterceptor,defaultResult,resourceLookupInterceptor,defaultRefererResult,executeMethodInterceptor,XStreamXMLDeserializer,defaultLogicResult,defaultValidationViewsFactory,jstlLocalization,XStreamXMLSerialization,XStreamJSONPSerialization,exceptionHandlerInterceptor,outjectResult,XStreamJSONSerialization,defaultValidator,defaultPageResult,emptyResult,instantiateInterceptor,jsonDeserializer,applicationConfiguration,defaultMethodInfo,HTMLSerialization,emptyElementsRemoval,downloadInterceptor,XStreamConverters,JSR303Validator,parametersInstantiatorInterceptor,forwardToDefaultViewInterceptor,shortConverter,localDateConverter,primitiveBooleanConverter,stringConverter,localeBasedCalendarConverter,integerConverter,localTimeConverter,primitiveIntConverter,longConverter,floatConverter,primitiveDoubleConverter,primitiveFloatConverter,primitiveShortConverter,localDateTimeConverter,enumConverter,bigIntegerConverter,primitiveByteConverter,primitiveLongConverter,doubleConverter,booleanConverter,characterConverter,bigDecimalConverter,uploadedFileConverter,primitiveCharConverter,byteConverter,localeBasedDateConverter,VRaptorRequestProvider,httpServletRequestProvider,httpServletResponseProvider,httpSessionProvider,enhancedRequestExecution,defaultInterceptorStack,XStreamBuilderImpl,org.springframework.aop.config.internalAutoProxyCreator,quartzScheduler,hibernateJobProvider,pecaRepositoryImpl,erro404,jobProviders,ancSmallRepositoryImpl,taskHandler,taskFactory,parameterLoaderInterceptor,ancSmallController,schedulerCreator,defaultJobFactory,turnoRepositoryImpl,entityManagerFactoryCreator,JPATransactionInterceptor,entityManagerCreator,producaoRepositoryImpl,tasksMonitor,producaoController,paradaRepositoryImpl,taskValidatorFactory,JPAJobProvider]; root of factory hierarchy
14-06-30 14:32:00,023 [INFO] org.quartz.impl.StdSchedulerFactory - Using default implementation for ThreadExecutor
14-06-30 14:32:00,026 [INFO] org.quartz.simpl.SimpleThreadPool - Job execution threads will use class loader of thread: localhost-startStop-1
14-06-30 14:32:00,037 [INFO] org.quartz.core.SchedulerSignalerImpl - Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
14-06-30 14:32:00,038 [INFO] org.quartz.core.QuartzScheduler - Quartz Scheduler v.2.2.1 created.
14-06-30 14:32:00,039 [INFO] org.quartz.simpl.RAMJobStore - RAMJobStore initialized.
14-06-30 14:32:00,039 [INFO] org.quartz.core.QuartzScheduler - Scheduler meta-data: Quartz Scheduler (v2.2.1) 'DefaultQuartzScheduler' with instanceId 'NON_CLUSTERED'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
  Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.

14-06-30 14:32:00,039 [INFO] org.quartz.impl.StdSchedulerFactory - Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
14-06-30 14:32:00,039 [INFO] org.quartz.impl.StdSchedulerFactory - Quartz scheduler version: 2.2.1
14-06-30 14:32:00,040 [INFO] org.quartz.core.QuartzScheduler - JobFactory set to: br.com.caelum.vraptor.tasks.jobs.DefaultJobFactory@1015ad1
14-06-30 14:32:00,043 [INFO] org.quartz.core.QuartzScheduler - Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
14-06-30 14:32:00,047 [INFO] org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@195de2f: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,defaultResourceTranslator,defaultRouter,defaultRoutes,objenesisInstanceCreator,defaultTypeNameExtractor,JSR303ValidatorFactory,pathAnnotationRoutesParser,defaultResourceNotFoundHandler,encodingHandlerFactory,interceptorListPriorToExecutionExtractor,defaultInterceptorHandlerFactory,defaultAcceptHeaderToFormat,cglibProxifier,messageInterpolatorFactory,topologicalSortedInterceptorRegistry,defaultRestDefaults,defaultMultipartConfig,hibernateProxyInitializer,paranamerNameProvider,defaultTypeFinder,defaultMethodNotAllowedHandler,javaEvaluator,defaultDeserializers,XStreamConverters.NullConverter,noRoutesConfiguration,defaultConverters,validatorFactoryCreator,stereotypeHandler,converterHandler,interceptorStereotypeHandler,deserializesHandler,stereotypedBeansRegistrar,defaultSpringLocator,ognlFacade,defaultHttpResult,defaultRepresentationResult,replicatorOutjector,defaultFormatResolver,defaultServletFileUploadCreator,defaultStatus,deserializingInterceptor,defaultRestHeadersHandler,defaultPathResolver,ognlParametersProvider,messageConverter,flashInterceptor,sessionFlashScope,defaultExceptionMapper,commonsUploadMultipartInterceptor,defaultResult,resourceLookupInterceptor,defaultRefererResult,executeMethodInterceptor,XStreamXMLDeserializer,defaultLogicResult,defaultValidationViewsFactory,jstlLocalization,XStreamXMLSerialization,XStreamJSONPSerialization,exceptionHandlerInterceptor,outjectResult,XStreamJSONSerialization,defaultValidator,defaultPageResult,emptyResult,instantiateInterceptor,jsonDeserializer,applicationConfiguration,defaultMethodInfo,HTMLSerialization,emptyElementsRemoval,downloadInterceptor,XStreamConverters,JSR303Validator,parametersInstantiatorInterceptor,forwardToDefaultViewInterceptor,shortConverter,localDateConverter,primitiveBooleanConverter,stringConverter,localeBasedCalendarConverter,integerConverter,localTimeConverter,primitiveIntConverter,longConverter,floatConverter,primitiveDoubleConverter,primitiveFloatConverter,primitiveShortConverter,localDateTimeConverter,enumConverter,bigIntegerConverter,primitiveByteConverter,primitiveLongConverter,doubleConverter,booleanConverter,characterConverter,bigDecimalConverter,uploadedFileConverter,primitiveCharConverter,byteConverter,localeBasedDateConverter,VRaptorRequestProvider,httpServletRequestProvider,httpServletResponseProvider,httpSessionProvider,enhancedRequestExecution,defaultInterceptorStack,XStreamBuilderImpl,org.springframework.aop.config.internalAutoProxyCreator,quartzScheduler,hibernateJobProvider,pecaRepositoryImpl,erro404,jobProviders,ancSmallRepositoryImpl,taskHandler,taskFactory,parameterLoaderInterceptor,ancSmallController,schedulerCreator,defaultJobFactory,turnoRepositoryImpl,entityManagerFactoryCreator,JPATransactionInterceptor,entityManagerCreator,producaoRepositoryImpl,tasksMonitor,producaoController,paradaRepositoryImpl,taskValidatorFactory,JPAJobProvider]; root of factory hierarchy
14-06-30 14:32:00,047 [INFO] org.quartz.core.QuartzScheduler - Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED shutting down.
14-06-30 14:32:00,047 [INFO] org.quartz.core.QuartzScheduler - Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED paused.
14-06-30 14:32:00,528 [INFO] org.quartz.core.QuartzScheduler - Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED shutdown complete.
Jun 30, 2014 2:32:00 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter vraptor
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'taskHandler': Unsatisfied dependency expressed through constructor argument with index 1 of type [java.util.List]: : No matching bean of type [br.com.caelum.vraptor.tasks.Task] found for dependency [collection of br.com.caelum.vraptor.tasks.Task]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [br.com.caelum.vraptor.tasks.Task] found for dependency [collection of br.com.caelum.vraptor.tasks.Task]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:730)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)
	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:293)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
	at br.com.caelum.vraptor.ioc.spring.SpringBasedContainer.start(SpringBasedContainer.java:106)
	at br.com.caelum.vraptor.ioc.spring.SpringProvider.start(SpringProvider.java:87)
	at br.com.caelum.vraptor.VRaptor.init(VRaptor.java:110)
	at br.com.caelum.vraptor.VRaptor.init(VRaptor.java:103)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4809)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5485)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [br.com.caelum.vraptor.tasks.Task] found for dependency [collection of br.com.caelum.vraptor.tasks.Task]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:924)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:751)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:795)
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:723)
	... 28 more

Jun 30, 2014 2:32:00 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
Jun 30, 2014 2:32:00 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/super] startup failed due to previous errors
Jun 30, 2014 2:32:00 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jun 30, 2014 2:32:00 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jun 30, 2014 2:32:00 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2989 ms
Jun 30, 2014 2:32:02 PM org.apache.catalina.core.StandardServer await
INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.
Jun 30, 2014 2:32:02 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Jun 30, 2014 2:32:03 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jun 30, 2014 2:32:03 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jun 30, 2014 2:32:03 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
Jun 30, 2014 2:32:03 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Jun 30, 2014 2:32:03 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
Jun 30, 2014 2:32:03 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]


Preciso mesmo configurar algo mais como xml ou properties?

Att.

Ailton

O erro fala que não existe implementação de Task…

vc precisa ter algum componente que implementa a interface Task.