Announcement Announcement Module
Collapse
No announcement yet.
Problem with flow within Step Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with flow within Step

    Dear Members

    In section
    5.3.6. Externalizing Flow Definitions and Dependencies Between Jobs

    Code:
    <job id="job">
        <step id="job1.flow1" flow="flow1" next="step3"/>
        <step id="step3" parent="s3"/>
    </job>
    
    <flow id="flow1">
        <step id="step1" parent="s1" next="step2"/>
        <step id="step2" parent="s2"/>
    </flow>
    I have the follow code

    Code:
    <flow id="preProcessingFlow">
    <step id="step1" parent="loadStockFile" next="step2"/>
    <step id="step2" parent="loadCustomerFile" next="step3"/>
    <step id="step3" parent="updateStartOfBatchCycle"/>
    </flow>
    
    <job id="flowJob">
    <step id="step0" flow="preProcessingFlow" next="step4"/>
    <step id="step4" parent="runBatch"/>
    </job>
    Practically the same configuration, but I get

    Code:
    org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: 
    Line 362
    in XML document from class path resource [jobs/statementJob.xml] is invalid; 
    nested exception is org.xml.sax.SAXParseException: 
    cvc-complex-type.3.2.2: Attribute 'flow' is not allowed to appear in element 'step'.
    What I am missing? or is a bug in Spring Batch documentation?

    Thanks in advanced

  • #2
    A step doesn't have a flow. It can have a parent that is a flow, but not a flow.

    Try

    Code:
    <job id="flowJob">
    <step id="step0" parent="preProcessingFlow" next="step4"/>
    <step id="step4" parent="runBatch"/>
    </job>

    Comment


    • #3
      A bit of time has passed since the last input to this thread but I think this is a bug - at least in the reference documentation if nothing else. I tried the configuration in the Spring Batch reference doc and got the same result as the above - it definitely seems to be invalid.
      I also tried the suggested change above and this still does not work. Error is:
      Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'job1': Cannot create inner bean '(inner bean)' of type [org.springframework.batch.core.configuration.xml.S impleFlowFactoryBean] while setting bean property 'flow'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '(inner bean)#4': Cannot create inner bean '(inner bean)' of type [org.springframework.batch.core.job.flow.support.St ateTransition] while setting bean property 'stateTransitions' with key [3]; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '(inner bean)#7': Cannot create inner bean '(inner bean)' of type [org.springframework.batch.core.job.flow.support.st ate.StepState] while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDepen dencyException: Error creating bean with name '(inner bean)#7': Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.batch.core.Step]: Could not convert constructor argument value of type [org.springframework.batch.core.job.flow.support.Si mpleFlow] to required type [org.springframework.batch.core.Step]: Failed to convert value of type 'org.springframework.batch.core.job.flow.support.S impleFlow' to required type 'org.springframework.batch.core.Step'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.batch.core.job.flow.support.Si mpleFlow] to required type [org.springframework.batch.core.Step]: no matching editors or conversion strategy found
      Related cause: org.springframework.beans.factory.UnsatisfiedDepen dencyException: Error creating bean with name '(inner bean)#7': Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.String]: Could not convert constructor argument value of type [org.springframework.batch.core.job.flow.support.Si mpleFlow] to required type [java.lang.String]: Failed to convert value of type 'org.springframework.batch.core.job.flow.support.S impleFlow' to required type 'java.lang.String'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.batch.core.job.flow.support.Si mpleFlow] to required type [java.lang.String]: no matching editors or conversion strategy found


      Config was:
      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:batch="http://www.springframework.org/schema/batch"
      xsi:schemaLocation="http://www.springframework.org/schema/batch
      http://www.springframework.org/schem...-batch-2.1.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

      <job id="job1" xmlns="http://www.springframework.org/schema/batch">
      <step id="job1.step1" next="job1.step2">
      <tasklet ref="tasklet1" />
      </step>
      <step id="job1.step2" parent="flow1"/>

      </job>
      <flow id="flow1" xmlns="http://www.springframework.org/schema/batch">
      <step id="flow1.step1" >
      <tasklet ref="flow1.tasklet1" />
      </step>
      </flow>

      <bean id="tasklet1" class="com.sample.SampleTasklet"/>

      <bean id="flow1.tasklet1" class="com.sample.SampleTasklet"/>

      </beans>


      So it appears that the parent property of a step can't be a flow. Have I done something wrong here?

      Comment

      Working...
      X