Version info: spring-batch-2.0.0-RELEASE and spring 2.5.6, quartz (1.6.2 and 1.6.5)
I have been successful running a job using CommandLineJobRunner with this configuration:
java org.springframework.batch.core.launch.support.Comm andLineJobRunner myJob.xml myJob.Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:j="http://www.springframework.org/schema/batch" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.0.xsd"> <!-- dataSource, itemReader, itemProcessor, itemWriter details removed --> <j:job id="myJob"> <j:step id="step1"> <j:tasklet> <j:chunk reader="itemReader" processor="itemProcessor" writer="itemWriter" commit-interval="1" /> </j:tasklet> </j:step> </j:job> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" lazy-init="true"> <property name="dataSource" ref="dataSource" /> </bean> <bean id="jobRepository" class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean"> <property name="transactionManager" ref="transactionManager"/> </bean> <bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher"> <property name="jobRepository" ref="jobRepository" /> </bean> </beans>
When converting to use Quartz I used the footbal.xml and quartz-job-launcher-context.xml as example. I made the following changes to jobLauncher:
and then added the following beans:Code:<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher"> <property name="jobRepository" ref="jobRepository" /> <property name="taskExecutor"> <bean class="org.springframework.core.task.SimpleAsyncTaskExecutor" /> </property> </bean>
I have been looking thru the footballJob example for things I have missed without luck. Here are the logs:Code:<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail" ref="jobDetail" /> <property name="cronExpression" value="0/30 * * * * ?" /> </bean> </property> </bean> <bean id="jobDetail" class="org.springframework.scheduling.quartz.JobDetailBean"> <property name="jobClass" value="org.springframework.batch.sample.quartz.JobLauncherDetails" /> <property name="group" value="quartz-batch" /> <property name="jobDataAsMap"> <map> <entry key="jobName" value="myJob"/> <entry key="jobLocator" value-ref="jobRegistry"/> <entry key="jobLauncher" value-ref="jobLauncher"/> </map> </property> </bean> <bean id="jobRegistry" class="org.springframework.batch.core.configuration.support.MapJobRegistry" />
Code:C:\>java org.springframework.batch.core.launch.support.JobRegistryBackgroundJobRunner myJob.xml May 26, 2009 11:19:07 AM org.springframework.batch.core.launch.support.JobRegistryBackgroundJobRunner main INFO: Starting job registry in parent context from XML at: [myJob.xml] May 26, 2009 11:19:07 AM org.springframework.batch.core.launch.support.JobRegistryBackgroundJobRunner main INFO: Waiting for parent context to start. May 26, 2009 11:19:07 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1f42b49: display name [org.springframework.context.support.ClassPathXmlApplicationContext@1f42b49]; startup date [Tue May 26 11:19:07 PDT 2009]; root of context hierarchy May 26, 2009 11:19:07 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [myJob.xml] May 26, 2009 11:19:07 AM org.springframework.beans.factory.support.DefaultListableBeanFactory registerBeanDefinition INFO: Overriding bean definition for bean 'myJob': replacing [Generic bean: class [org.springframework.batch.core.job.flow.support.SimpleFlow]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Generic bean: class [org.springframework.batch.core.job.flow.FlowJob]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] May 26, 2009 11:19:07 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@1f42b49]: org.springframework.beans.factory.support.DefaultListableBeanFactory@210b5b May 26, 2009 11:19:07 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@210b5b: defining beans [dataSource,itemReader,itemWriter,itemProcessor,org.springframework.batch.core.scope.internalStepScope,org.springframework.beans.factory.config.CustomEditorConfigurer,step1,myJob,transactionManager,jobRepository,jobLauncher,org.springframework.scheduling.quartz.SchedulerFactoryBean#0,jobDetail,jobRegistry]; root of factory hierarchy May 26, 2009 11:19:08 AM org.quartz.core.SchedulerSignalerImpl <init> INFO: Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl May 26, 2009 11:19:08 AM org.quartz.core.QuartzScheduler <init> INFO: Quartz Scheduler v.1.6.2 created. May 26, 2009 11:19:08 AM org.quartz.simpl.RAMJobStore initialize INFO: RAMJobStore initialized. May 26, 2009 11:19:08 AM org.quartz.impl.StdSchedulerFactory instantiate INFO: Quartz scheduler 'org.springframework.scheduling.quartz.SchedulerFactoryBean#0' initialized from an externally provided properties instance. May 26, 2009 11:19:08 AM org.quartz.impl.StdSchedulerFactory instantiate INFO: Quartz scheduler version: 1.6.2 May 26, 2009 11:19:08 AM org.quartz.core.QuartzScheduler setJobFactory INFO: JobFactory set to: org.springframework.scheduling.quartz.AdaptableJobFactory@7a4489 May 26, 2009 11:19:08 AM org.springframework.scheduling.quartz.SchedulerFactoryBean startScheduler INFO: Starting Quartz Scheduler now May 26, 2009 11:19:08 AM org.quartz.core.QuartzScheduler start INFO: Scheduler org.springframework.scheduling.quartz.SchedulerFactoryBean#0_$_NON_CLUSTERED started. May 26, 2009 11:19:08 AM org.springframework.batch.core.launch.support.JobRegistryBackgroundJobRunner main INFO: Parent context started. Registering jobs from paths: [] Started application. Interrupt (CTRL-C) or call JobRegistryBackgroundJobRunner.stop() to exit. May 26, 2009 11:19:15 AM com.verizonwireless.springbatchtest.JobLauncherDetails executeInternal INFO: Quartz trigger firing with Spring Batch jobName=myJob May 26, 2009 11:19:15 AM org.springframework.batch.sample.quartz.JobLauncherDetails executeInternal SEVERE: Could not execute job. org.springframework.batch.core.launch.NoSuchJobException: No job configuration with the name [myJob] was registered at org.springframework.batch.core.configuration.support.MapJobRegistry.getJob(MapJobRegistry.java:79) at com.verizonwireless.springbatchtest.JobLauncherDetails.executeInternal(JobLauncherDetails.java:46) at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525) May 26, 2009 11:19:30 AM com.verizonwireless.springbatchtest.JobLauncherDetails executeInternal


Reply With Quote