Reputation: 5189
I have the following step defined in my spring batch project. I've simplified the code for brevity.
@Bean
@JobScope
public JdbcCursorItemReader<MasterList> queryStagingDbReader(
@Value("#{jobExecutionContext['" + ExecutionContextConstants.JOB_EXPORT_STAGING_PROMOTION_START_DATE_END_DATE_GROUPINGS +"']}")
List<PromotionStartDateEndDateGrouping> promotionStartDateEndDateGroupings,
@Value("#{jobExecutionContext}")Map<String, Object> jobExecutionContext) {
jobExecutionContext.put(ExecutionContextConstants.JOB_EXPORT_STAGING_WORKING_PROMOTION_START_DATE_END_DATE, "Hello");
}
My problem is that when I try to add to the jobExecutionContext as per the put statment above I get ...
Caused by: java.lang.UnsupportedOperationException: null
at java.util.Collections$UnmodifiableMap.put(Collections.java:1457) ~
If this does not work how can I add to the jobExecutionContext?
thanks in advance
Upvotes: 0
Views: 1518
Reputation: 21453
What are you receiving there is not the actual ExecutionContext
. It's a Map
with the values within the ExecutionContext
. To obtain the actual ExecutionContext
, you'd need to grab it from the JobExecution
itself. That being said, in most cases, StepScope
is more appropriate or the native singleton.
Upvotes: 2