[SHDP-34] Support property replacement of Spring Batch Job Parameters in Script Tasklet and all Job Types Created: 17/Feb/12  Updated: 19/Apr/12  Resolved: 19/Apr/12

Status: Resolved
Project: Spring for Apache Hadoop
Component/s: FS, MR
Affects Version/s: None
Fix Version/s: 1.0.0.M2

Type: New Feature Priority: Major
Reporter: Mark Pollack Assignee: Costin Leau
Resolution: Complete Votes: 0
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

SHDP-52 batch job params support for MR tasks Sub-task Resolved Costin Leau  
SHDP-53 batch job params support for scriptin... Sub-task Resolved Costin Leau  


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


{jobParameters['input.file']}", inputPath);

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)

Generated at Sat Jul 04 19:52:56 UTC 2020 using Jira 8.5.4#805004-sha1:0444eab799707f9ad7b248d69f858774aadfd250.