Uploaded image for project: 'Spring for Apache Hadoop'
  1. Spring for Apache Hadoop
  2. SHDP-34

Support property replacement of Spring Batch Job Parameters in Script Tasklet and all Job Types

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 1.0.0.M2
    • Component/s: FS, MR
    • Labels:
      None

      Description

      Would like to be able to support
      <script-tasklet id="script-tasklet">
      <script language="groovy">

      .....
      fsh.copyFromLocal("#

      {jobParameters['input.file']}", inputPath);
      </script>
      </script-tasklet>


      The #{jobParameters['input.file']}

      uses SpEL to evaluate the expression and Batch populated the SpEL context with the jobParameters map. See http://static.springsource.org/spring-batch/reference/html/configureStep.html#late-binding

      tried some quick solutions but didn't dive into the details. this is what is known so far.

      Setting only the ScriptTaskletParser to be of scope=step failed with

      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.data.hadoop.scripting.HdfsScriptFactoryBean#0': Cannot create inner bean '(inner bean)' of type [org.springframework.scripting.support.StaticScriptSource] while setting bean property 'scriptSource'; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'jobParameters' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext

      and setting ScriptParser to scope=step in addition gives a more unusual error

      Caused by: org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'input' of bean class [org.springframework.batch.core.scope.context.StepContext]: Bean property 'input' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
      at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:141)

        Attachments

          Activity

            People

            • Assignee:
              costin Costin Leau
              Reporter:
              mark.pollack Mark Pollack
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: