在jobExecutionContext中存储Map / List数据类型

时间:2014-10-31 05:48:24

标签: deserialization spring-batch executioncontext

有一个弹簧批处理作业,它将地图/列表存储在jobexeutioncontext中,用于商业逻辑, 和如果它第一次失败并尝试重新启动,它总是发生如下错误:

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)

当它从DB CLOB读取jobexecutioncontext时 看起来像XStream 1.3的反序列化问题......

我尝试了降级到XStream 1.2.2之类的东西,但根本没用。 所以我修复了批处理程序,它将map / list存储在jobexexcutioncontext下面

AfterJobListener类

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());

现在正在运作。

所以问题是 - 还有另一种方法来逃避这个错误吗? 我的网站使用spring-batch-core-2.1.5 websphere 7.0.0.17上的springframework-core 3.0.2

由于

0 个答案:

没有答案
相关问题