Announcement Announcement Module
Collapse
No announcement yet.
Error JobRepository is mandatory IN SIMPLE JOB Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error JobRepository is mandatory IN SIMPLE JOB

    Dear friends, I am trying to load my xml to job but is giving the error JobRepository is mandatory.

    I saw an example of Dave Syer at https://fisheye.springsource.org/rdi...h?Csid=751&u&N on setting the properties of a step abstract, but in my case is a simple job with just one step , nothing sophisticated.

    Below the stack trace of the error and the infrastructure used by my job

    Do I know why this error is occurring to increase my JOB?

    Now thanks.


    Error:
    Code:
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requesterElectronicInvoice': Cannot create inner bean '(inner bean)' of type [org.springframework.batch.core.job.flow.support.SimpleFlow] while setting bean property 'flow'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot create inner bean '(inner bean)' of type [org.springframework.batch.core.job.flow.support.StateTransition] while setting bean property 'stateTransitions' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot create inner bean '(inner bean)' of type [org.springframework.batch.core.job.flow.support.state.StepState] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'step1' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'step1': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: JobRepository is mandatory
    Job
    Code:
     <beans:beans xmlns="http://www.springframework.org/schema/batch" 
         xmlns:beans="http://www.springframework.org/schema/beans" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="
               http://www.springframework.org/schema/beans 
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
               http://www.springframework.org/schema/batch 
               http://www.springframework.org/schema/batch/spring-batch-2.0.xsd">
               
    	<beans:import resource="simple-job-launcher-context.xml" />
    	
    	<job id="requesterElectronicInvoice" job-repository="jobRepository">
    		<step id="step1">
    			<tasklet transaction-manager="transactionManager">
    				<chunk 
    						reader="hibernateItemReader"  
    						processor="ProcessorRps"  
    						writer="itemWriter"  
    						commit-interval="10" />
    			</tasklet>
    		</step>
    	</job>
    
    	<beans:bean id="ReaderInvoice" class="br.com.moip.jobs.rnf.ReaderInvoice">
    		<beans:property name="sessionFactory" ref="sessionFactory" />
    	</beans:bean>
    
    	<beans:bean id="hibernateItemReader"
    			class="org.springframework.batch.item.database.HibernateCursorItemReader">		
    		<beans:property name="queryString" value="from PaymentUsed where status = 1"/>
    		<beans:property name="sessionFactory" ref="sessionFactory" />
    	</beans:bean>
    	
    	<beans:bean id="ProcessorRps" class="br.com.moip.jobs.rnf.ProcessorInvoice"/>
    	
    	<beans:bean id="itemWriter"
    		class="br.com.moip.jobs.rnf.WriterInvoice">
    			<beans:property name="sessionFactory" ref="sessionFactory" />		
    	</beans:bean>
    	
    		
    
    </beans:beans>
    Job Launcher
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    	xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="
    		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    	
    	<import resource="applicationContext-DAO.xml"/>
    	<bean id="jobRepository"
    		class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"
    		p:dataSource-ref="dataSource" p:transactionManager-ref="transactionManager">		
    	 </bean>
    		
    
    	<bean id="jobLauncher"
    		class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
    		<property name="jobRepository" ref="jobRepository" />
    	</bean>
    
    	<bean class="org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor">
    		<property name="jobRegistry" ref="jobRegistry"/>
    	</bean>
    	
    	<bean id="mapJobRepository"
    		class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean"
    		lazy-init="true" autowire-candidate="false" />
    
    	<bean id="jobOperator"
    		class="org.springframework.batch.core.launch.support.SimpleJobOperator"
    		p:jobLauncher-ref="jobLauncher" p:jobExplorer-ref="jobExplorer"
    		p:jobRepository-ref="jobRepository" p:jobRegistry-ref="jobRegistry" />
    
    	<bean id="jobExplorer"
    		class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean"
    		p:dataSource-ref="dataSource" />
    
    	<bean id="jobRegistry"
    		class="org.springframework.batch.core.configuration.support.MapJobRegistry" />	
    
    
    </beans>

  • #2
    Circumvented Problem

    Colleagues, could solve the problem changing my version of Spriger bacth to version 2.0.1 to 2.0.0.
    I looked at the release notes: http://static.springsource.org/sprin...0.0-2.0.1.html but could not identify which bug problem concerned the problem.

    Now be recorded as work around the problem.

    Someone has been this problem before?
    This would apply to register at some place?

    Comment


    • #3
      It's not really a bug. Maybe a feature. You could also use 2.0.1 (or a 2.0.2 snapshot) if you either 1) remove the job-repository attribute from the job, or 2) use a parent step that injects the job repository. If the job has an explicit job repository then we have to assume that you intend to override the default in all the steps as well (since it doesn't make sense to use a different one in the steps to he job), but we can't actually do the override for you. Since you are using the default value it is better for you to simply leave it out.

      Comment


      • #4
        Hi
        Dave's suggestion worked for me. I removed the jobRepository from job defination and added to step. It worked with 2.0.1 batch infrastructure and core libs.

        Comment

        Working...
        X