Results 1 to 8 of 8

Thread: wrong xsd? wrong attributes for tasklet

  1. #1
    Join Date
    May 2009
    Posts
    7

    Default wrong xsd? wrong attributes for tasklet

    I just try to migrate from Spring Batch 1.1 to 2.0.0

    When I try to use the property "reader" for the element "tasklet" as in the examples I get an XML-parsing error which says:

    Attribute 'reader' is not allowed to appear in element 'batch:tasklet'

    Code:
    <beans xmlns="http://www.springframework.org/schema/beans" 
         xmlns:batch="http://www.springframework.org/schema/batch" 
         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.0.xsd
               http://www.springframework.org/schema/batch 
               http://www.springframework.org/schema/batch/spring-batch-2.0.xsd">
    
    	<batch:job id="importJob2" parent="simpleJob">
    		<batch:step id="userSummary" parent="simpleStep">
          		<batch:tasklet reader="userSummaryReader" writer="hibernateItemWriter" commit-interval="10" >
          		</batch:tasklet>
        	</batch:step>
    	</batch:job>
    I've got the spring-batch-core-2.0.0.RELEASE.jar in my classpath. When I verify the contained spring-batch-2.0.xsd I cannot find the definition for the attributes reader or writer in it. Am I using the wrong jar or is there really no usage of a reader or writer for the element tasklet?

  2. #2
    Join Date
    Feb 2008
    Posts
    488

    Default

    The "reader" etc attributes were moved to a subelement called <chunk/> to make sure the distinction between a TaskletStep and a chunk-oriented tasklet step was clear:

    Code:
     <job id="sampleJob">
        <step id="step1">
          <tasklet>
              <chunk reader="itemReader" writer="itemWriter" commit-interval="10"/>
          <tasklet>
        </step>
      </job>
    See http://static.springsource.org/sprin...p.html#d0e2424

  3. #3
    Join Date
    May 2009
    Posts
    7

    Default

    Thanks for the information!

    But then the doc is not up to date because I found this in 6.3.1:

    Code:
      <job id="ioSampleJob">
        <step name="step1">
          <tasklet reader="fooReader" processor="compositeProcessor" writer="foobarWriter" commit-interval="2"/>
        </step>
      </job>
    and somehow my IDE (Eclipse) still thinks these attributes are for the tasklet element. I wonder where it holds this xsd.
    Last edited by volker; May 5th, 2009 at 02:25 PM.

  4. #4
    Join Date
    Feb 2008
    Posts
    488

    Default

    I'll correct that in the docs.

  5. #5
    Join Date
    May 2009
    Posts
    2

    Default

    But what if you have a step that is not step oriented? I thought that the whole point of the <tasklet ref="..."> was to avoid having to configure a reader which only returned null?

  6. #6
    Join Date
    Feb 2008
    Posts
    488

    Default

    The ref= attribute is used for referencing a Tasklet (non-chunk-oriented). The <chunk/> element is used for a chunk-oriented step. You must have one or the other, and you can't have both.

  7. #7
    Join Date
    May 2009
    Posts
    2

    Default

    But I'm getting a xml validation error when I try to use a ref attribute in a tasklet tag. In fact, I'm totally confused about what the actual spring-batch xsd is. I get one schema if I hit the url http://www.springframework.org/schem...-batch-2.0.xsd. I get any entirely different schema (it appears) when I look in the 2.0.0.RC1 jar. It appears that one is used when I run in Eclipse, and another when I run from a command line. In short, I have no idea what the job tag is supposed to look like.

  8. #8
    Join Date
    Feb 2008
    Posts
    488

    Default

    You should be using the 2.0.0.RELEASE jar. A lot has changed since RC1.

    You can check the documentation to see how to use the namespace:
    http://static.springsource.org/sprin...b.html#d0e1558
    http://static.springsource.org/sprin...p.html#d0e2424

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •