I have developed a spring batch for loading users into a DB. I am able to run it as a Java Application from eclipse providing the main class but not able to run the batch by a shell script on a unix server. I get this exception:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'jobLauncher' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:529)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1095)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:277)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1093)
at com.batch.LoadBatch.launchJob(LoadBatch.java:56)
at com.batch.LoadBatch.main(LoadBatch.java:38)
I have my beans declared in a job.xml file as follows
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:context="http://ift.tt/GArMu7"
xmlns:batch="http://ift.tt/1fayA4Z"
xsi:schemaLocation="http://ift.tt/1fayA4Z
http://ift.tt/1snNyHz
http://ift.tt/GArMu6
http://ift.tt/1cMYE2s
http://ift.tt/18IIlo0
http://ift.tt/1kcMSzH"">
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:LoadBatch.properties </value>
</property>
</bean>
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
<property name="transactionManager" ref="transactionManager" />
</bean>
<bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
<!--
*****************************productLoadJob********************************
-->
<bean id="completionPolicy" class="org.springframework.batch.repeat.policy.DefaultResultCompletionPolicy"/>
<bean id="multiResourceReader"
class=" org.springframework.batch.item.file.MultiResourceItemReader" scope="step">
<property name="resources" value="http://file/${inputFilePath}*.csv" />
<property name="delegate" ref="flatFileItemReader" />
</bean>
<bean id="flatFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="fieldSetMapper">
<bean class="com.tcs.telecom.tib.irBatch.mapper.IndividualRetailerFieldSetMapper" />
</property>
<property name="lineTokenizer">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="delimiter" value="," />
</bean>
</property>
</bean>
</property>
<property name="linesToSkip" value="1" />
</bean>
<bean id="flatFileItemWriter"
class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step">
<property name="resource" value="file:${outputFilePath}${outputFileName}.${outputFileType}" />
<property name="appendAllowed" value="true" />
<property name="lineAggregator">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
<property name="delimiter" value="," />
<property name="fieldExtractor">
<bean
class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
<property name="names" value="serialNo,mobileNo,role,parentId" />
</bean>
</property>
</bean>
</property>
</bean>
<bean id="itemProcessor" class="com.handlers.LoadWriter" scope="step">
<property name="LoadFileHandler" ref="filehandler" />
<property name="LoadFieldSetMapper" ref="LoadFieldSetMapper"/>
<property name="opId" value="ABC" />
<property name="buId" value="XYZ" />
</bean>
<bean id="batchExceptionListner" class="com.handlers.LoadBatchExceptionListener" >
<property name="irLoadFileHandler" ref="filehandler" />
</bean>
<bean id="filehandler" class="com.handlers.IRLoadFileHandler" />
<bean id="IRLoadFieldSetMapper" class="com.handlers.IRLoadFieldSetMapper" />
<bean id="skipExceptionListner" class="com.handlers.IRLoadSkipExceptionListener" />
<batch:job id="IRLoadJob">
<batch:step id="importFileStep">
<batch:tasklet>
<batch:chunk reader="multiResourceReader" writer="flatFileItemWriter"
processor="itemProcessor" commit-interval="1">
</batch:chunk>
</batch:tasklet>
</batch:step>
<batch:listeners>
<batch:listener ref="batchExceptionListner" />
</batch:listeners>
</batch:job>
</beans>
Aucun commentaire:
Enregistrer un commentaire