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