0

there's a spring batch job which stores map/list in jobexeutioncontext for biz logic, and if it failed first-time and tried restart it, it always occurred error like below :

java.lang.InstantiationError: java.util.Map$Entry
at sun.reflect.GeneratedSerializationConstructorAccessor147.newInstance(Unknown Source)
....
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:853)
at org.springframework.batch.core.repository.dao.XStreamExecutionContextStringSerializer.deserialize(XStreamExecutionContextStringSerializer.java:48)

cause when it read jobexecutioncontext from DB CLOB looks like deserialization problem with XStream 1.3...

I tried something like degrade to XStream 1.2.2, but didn't work at all. So I fixed batch-program which stores map/list in jobexexcutioncontext below

AfterJobListener class

protected void afterJob() {

for (Entry<String, Object     entry : getJobExecutionContext().entrySet()) {
                String key = entry.getKey();
                Object value = entry.getValue();
                //log.debug("key:" + key + ", value:" + value);
                if (value instanceof Map || value instanceof List) {
                    //log.debug("Del key:" + key + ",Del value:" + value);
                    getJobExecutionContext().remove(key);
                }
            }
        }
jobRepository.updateExecutionContext(getJobExecution());

and now is working.

So the question is - is there another way to escape this error? My site using spring-batch-core-2.1.5 springframework-core 3.0.2 on websphere 7.0.0.17

Thanks

Bumz
  • 1
  • For starters, you may want to upgrade your versions (specifically Spring Batch and Spring). I'm 99% sure storing a Collection in the `ExecutionContext` works in the more recent versions (the TCK of JSR-352 does that I believe and we pass that). – Michael Minella Oct 31 '14 at 14:46
  • our site has been managed a batch system for 4 years with spring-batch-core-2.1.5 and upgrading to recent version is never allowed until next full change of system for maintenance issue. thanks for replying and I always get big helps from spring forum... – Bumz Nov 04 '14 at 01:30

0 Answers0