Announcement Announcement Module
Collapse
No announcement yet.
wrong xsd? wrong attributes for tasklet Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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, 02:25 PM.

      Comment


      • #4
        I'll correct that in the docs.

        Comment


        • #5
          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?

          Comment


          • #6
            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.

            Comment


            • #7
              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.

              Comment


              • #8
                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

                Comment

                Working...
                X