Announcement Announcement Module
Collapse
No announcement yet.
About step tag behaviour Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • About step tag behaviour

    Dear members

    After to read the documentation and see in a skim way the sample code configuration
    offered by Spring Batch

    Code:
      <job id="footballJob">
        <step id="playerload" next="gameLoad"/>
        <step id="gameLoad" next="playerSummarization"/>
        <step id="playerSummarization"/>
      </job>
    is mandatory that each id must be a bean class?

    I am doing this question because, I have this for instance (consider an experiment)

    Code:
    	<job
    		job-repository="jobRepository"
    		id="insertIntoDbFromCsvJob">
    		<step id="step1">
    			<next on="COMPLETED" to="step2" />			
    		</step>		
    
    		<step id="step2">
    			<tasklet>
    				<chunk 
    					reader="csvFileReader"
    					writer="jdbcItemWriter"
    					commit-interval="10" 
    					retry-limit="3" 
    					cache-capacity="10">
    						<retryable-exception-classes>
    	  org.springframework.dao.DeadlockLoserDataAccessException
    						</retryable-exception-classes>	
    				</chunk>				
    			</tasklet>
    		</step>
    	</job>
    If I run therefore this error appear

    Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJava Mojo.java:283)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'step1': Instantiation of bean failed; nested exception is java.lang.IllegalStateException: No bean class specified on bean definition
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateBean(Abstrac tAutowireCapableBeanFactory.java:883)
    but If instead use

    Code:
        <job
    	job-repository="jobRepository"
    	id="insertIntoDbFromCsvJob">
    	<step id="step1">		
    		<tasklet>
    			<chunk 
    				reader="csvFileReader"
    				writer="jdbcItemWriter"
    				commit-interval="10" 
    				processor="userRegistrationValidationProcessor" />
                    </tasklet>		
    		<next on="COMPLETED" to="step2" />			
    	</step>	
             ......
         </job>
    Ignote that the tasklet is practically repeated

    The point is that I dont have the error anymore if I include a tasklet
    therefore why this behaviour?

    Thanks in advanced

  • #2
    <step id="step1">
    <next on="COMPLETED" to="step2" />
    </step>
    Did you find this code in some of our documentation? It will not work because you're not giving any definition for your step. I'm not sure what your first step is supposed to do, but you're not telling it to do anything.

    When you add the <tasklet/> and <chunk/>, it works because this is actually defining the step.

    Comment


    • #3
      Hello DHGarrette

      thanks for the reply

      Did you find this code in some of our documentation?
      this I found it just here (Configuration enhancements)

      Code:
       <job id="footballJob">
          <step id="playerload" next="gameLoad"/>
          <step id="gameLoad" next="playerSummarization"/>
          <step id="playerSummarization"/>
        </job>
      it was an introduction, after deeper explanation appear

      I'm not sure what your first step is supposed to do, but you're not telling it to do anything.
      Yes, I see my error

      Thanks for the explanation

      Regards

      Comment


      • #4
        Originally posted by dr_pompeii View Post
        this I found it just here (Configuration enhancements)
        Yep, this example is wrong. I've just created an issue to fix it: http://jira.springframework.org/browse/BATCH-1315.

        Thanks for letting me know!

        Comment


        • #5
          Hello Dan

          Yep, this example is wrong. I've just created an issue to fix it: http://jira.springframework.org/browse/BATCH-1315.

          Thanks for letting me know!
          Thanks to you for write with the other members the documentation

          Best Regards

          Comment

          Working...
          X