Announcement Announcement Module
Collapse
No announcement yet.
MapExecutionContextDao blew up when I used in the below configuration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MapExecutionContextDao blew up when I used in the below configuration

    MapExecutionContextDao blew up when I used in the below configuration

    <bean id="jobRepository" class="org.springframework.batch.core.repository.s upport.SimpleJobRepository">
    <constructor-arg>
    <bean class="org.springframework.batch.core.repository.d ao.MapJobInstanceDao"/>
    </constructor-arg>
    <constructor-arg>
    <bean class="org.springframework.batch.core.repository.d ao.MapJobExecutionDao" />
    </constructor-arg>
    <constructor-arg>
    <bean class="org.springframework.batch.core.repository.d ao.MapStepExecutionDao" />
    </constructor-arg>
    <constructor-arg>
    <bean class="org.springframework.batch.core.repository.d ao.MapExecutionContextDao"/>
    </constructor-arg>
    </bean>

    <batch:job id="PLC_JOB">
    <!--
    the below steps are running parallel configured statically
    -->
    <batch:split id="split1" task-executor="taskExecutor" next="step3">
    <batch:flow>
    <batch:step id="step1" parent="cdsFetchStepPRDIM" />
    </batch:flow>
    <batch:flow>
    <batch:step id="step2" parent="cdsFetchStepPRLED" />
    </batch:flow>
    </batch:split>
    <!--
    the below step will run in partitions of steps dynamically determined
    -->
    <batch:step id="step3" parent="partitionedSenderStep"/>
    </batch:job>


    1.0 2011-08-03 18:38:52,267 GMT+0000 vjb00012 [taskExecutor-2] ERROR 4423 AbstractStep.execute Encountered an error executing the step: class org.springframework.batch.core.step.AbstractStep$F atalException: Fatal failure detected
    org.springframework.batch.core.step.AbstractStep$F atalException: Fatal failure detected
    at org.springframework.batch.core.step.tasklet.Taskle tStep$2.doInChunkContext(TaskletStep.java:303)
    at org.springframework.batch.core.scope.context.StepC ontextRepeatCallback.doInIteration(StepContextRepe atCallback.java:67)
    at org.springframework.batch.repeat.support.RepeatTem plate.getNextResult(RepeatTemplate.java:352)
    at org.springframework.batch.repeat.support.RepeatTem plate.executeInternal(RepeatTemplate.java:212)
    at org.springframework.batch.repeat.support.RepeatTem plate.iterate(RepeatTemplate.java:143)
    at org.springframework.batch.core.step.tasklet.Taskle tStep.doExecute(TaskletStep.java:239)
    at org.springframework.batch.core.step.AbstractStep.e xecute(AbstractStep.java:197)
    at org.springframework.batch.core.job.AbstractJob.han dleStep(AbstractJob.java:348)
    at org.springframework.batch.core.job.flow.FlowJob.ac cess$100(FlowJob.java:43)
    at org.springframework.batch.core.job.flow.FlowJob$Jo bFlowExecutor.executeStep(FlowJob.java:137)
    at org.springframework.batch.core.job.flow.support.st ate.StepState.handle(StepState.java:60)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.resume(SimpleFlow.java:144)
    at org.springframework.batch.core.job.flow.support.Si mpleFlow.start(SimpleFlow.java:124)
    at org.springframework.batch.core.job.flow.support.st ate.SplitState$1.call(SplitState.java:82)
    at org.springframework.batch.core.job.flow.support.st ate.SplitState$1.call(SplitState.java:80)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unkn own Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
    at java.util.HashMap$EntryIterator.next(Unknown Source)
    at java.util.HashMap$EntryIterator.next(Unknown Source)
    at java.util.HashMap.putAllForCreate(Unknown Source)
    at java.util.HashMap.<init>(Unknown Source)
    at org.springframework.batch.support.transaction.Tran sactionAwareProxyFactory.begin(TransactionAwarePro xyFactory.java:75)
    at org.springframework.batch.support.transaction.Tran sactionAwareProxyFactory$1.invoke(TransactionAware ProxyFactory.java:115)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy1.put(Unknown Source)
    at org.springframework.batch.core.repository.dao.MapE xecutionContextDao.updateExecutionContext(MapExecu tionContextDao.java:55)
    at org.springframework.batch.core.repository.support. SimpleJobRepository.updateExecutionContext(SimpleJ obRepository.java:178)
    at org.springframework.batch.core.step.tasklet.Taskle tStep$2.doInChunkContext(TaskletStep.java:296)
    ... 19 more

  • #2
    Problem went away when I overrided MapExecutionContextDao s update methods and added synchronization as below

    package com.fedex.pricing.massupdate.support;

    import java.util.Map;

    import org.apache.commons.lang.SerializationUtils;
    import org.springframework.batch.core.JobExecution;
    import org.springframework.batch.core.StepExecution;
    import org.springframework.batch.core.repository.dao.MapE xecutionContextDao;
    import org.springframework.batch.item.ExecutionContext;
    import org.springframework.batch.support.transaction.Tran sactionAwareProxyFactory;

    public class MyMapExecutionContextDao extends MapExecutionContextDao {

    private static Map<Long, ExecutionContext> contextsByStepExecutionId = TransactionAwareProxyFactory
    .createTransactionalMap();

    private static Map<Long, ExecutionContext> contextsByJobExecutionId = TransactionAwareProxyFactory
    .createTransactionalMap();

    public static void clear() {
    contextsByJobExecutionId.clear();
    contextsByStepExecutionId.clear();
    }

    private static ExecutionContext copy(ExecutionContext original) {
    return (ExecutionContext) SerializationUtils.deserialize(SerializationUtils. serialize(original));
    }

    public ExecutionContext getExecutionContext(StepExecution stepExecution) {
    return copy(contextsByStepExecutionId.get(stepExecution.g etId()));
    }

    public void updateExecutionContext(StepExecution stepExecution) {
    synchronized(contextsByStepExecutionId){
    contextsByStepExecutionId.put(stepExecution.getId( ), copy(stepExecution.getExecutionContext()));
    }
    }

    public ExecutionContext getExecutionContext(JobExecution jobExecution) {
    return copy(contextsByJobExecutionId.get(jobExecution.get Id()));
    }

    public void updateExecutionContext(JobExecution jobExecution) {
    synchronized(contextsByStepExecutionId){
    contextsByJobExecutionId.put(jobExecution.getId(), copy(jobExecution.getExecutionContext()));
    }
    }

    public void saveExecutionContext(JobExecution jobExecution) {
    updateExecutionContext(jobExecution);
    }

    public void saveExecutionContext(StepExecution stepExecution) {
    updateExecutionContext(stepExecution);
    }

    }

    Comment

    Working...
    X