Announcement Announcement Module
Collapse
No announcement yet.
Spring Batch 2.1.8 XStreamExecutionContextStringSerializer hierarchicalStreamDriver Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Batch 2.1.8 XStreamExecutionContextStringSerializer hierarchicalStreamDriver

    Hi,

    I am trying to rerun a job which gives the below exception



    2011-06-02 20:10:09,629 [main] INFO org.springframework.batch.core.repository.support. JobRepositoryFactoryBean - No database type set, using meta data indicating: ORACLE
    Exception in thread "main" java.lang.InstantiationError: java.util.Map$Entry
    at sun.reflect.GeneratedSerializationConstructorAcces sor1.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Construc tor.java:513)
    at com.thoughtworks.xstream.converters.reflection.Sun 14ReflectionProvider.newInstance(Sun14ReflectionPr ovider.java:74)
    at com.thoughtworks.xstream.converters.reflection.Abs tractReflectionConverter.instantiateNewInstance(Ab stractReflectionConverter.java:308)
    at com.thoughtworks.xstream.converters.reflection.Abs tractReflectionConverter.unmarshal(AbstractReflect ionConverter.java:161)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.con vert(TreeUnmarshaller.java:82)
    at com.thoughtworks.xstream.core.AbstractReferenceUnm arshaller.convert(AbstractReferenceUnmarshaller.ja va:63)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.con vertAnother(TreeUnmarshaller.java:76)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.con vertAnother(TreeUnmarshaller.java:60)
    at com.thoughtworks.xstream.converters.collections.Ab stractCollectionConverter.readItem(AbstractCollect ionConverter.java:71)
    at com.thoughtworks.xstream.converters.collections.Ma pConverter.populateMap(MapConverter.java:75)
    at com.thoughtworks.xstream.converters.collections.Ma pConverter.unmarshal(MapConverter.java:66)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.con vert(TreeUnmarshaller.java:82)
    at com.thoughtworks.xstream.core.AbstractReferenceUnm arshaller.convert(AbstractReferenceUnmarshaller.ja va:63)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.con vertAnother(TreeUnmarshaller.java:76)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.con vertAnother(TreeUnmarshaller.java:60)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.sta rt(TreeUnmarshaller.java:137)
    at com.thoughtworks.xstream.core.AbstractTreeMarshall ingStrategy.unmarshal(AbstractTreeMarshallingStrat egy.java:33)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream .java:923)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream .java:909)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.j ava:853)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.j ava:845)
    at org.springframework.batch.core.repository.dao.XStr eamExecutionContextStringSerializer.deserialize(XS treamExecutionContextStringSerializer.java:48)
    at org.springframework.batch.core.repository.dao.Jdbc ExecutionContextDao$ExecutionContextRowMapper.mapR ow(JdbcExecutionContextDao.java:222)
    at org.springframework.batch.core.repository.dao.Jdbc ExecutionContextDao$ExecutionContextRowMapper.mapR ow(JdbcExecutionContextDao.java:1)
    at org.springframework.jdbc.core.RowMapperResultSetEx tractor.extractData(RowMapperResultSetExtractor.ja va:92)
    at org.springframework.jdbc.core.JdbcTemplate$1.doInP reparedStatement(JdbcTemplate.java:653)
    at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:591)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:641)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:670)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:678)
    at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:710)
    at org.springframework.jdbc.core.simple.SimpleJdbcTem plate.query(SimpleJdbcTemplate.java:187)
    at org.springframework.batch.core.repository.dao.Jdbc ExecutionContextDao.getExecutionContext(JdbcExecut ionContextDao.java:106)
    at org.springframework.batch.core.explore.support.Sim pleJobExplorer.getStepExecutionDependencies(Simple JobExplorer.java:190)
    at org.springframework.batch.core.explore.support.Sim pleJobExplorer.findRunningJobExecutions(SimpleJobE xplorer.java:99)
    at org.springframework.batch.core.launch.support.Simp leJobOperator.getRunningExecutions(SimpleJobOperat or.java:208)

    The data I am trying to read for step execution context is

    {"map":[{"entry":{"string":"FlatFileItemReader.read.count" ,"int":100}}]}.


    The existing jdbcexecutioncontextdao class uses XStreamExecutionContextStringSerializer which I couldn't override . There seems to be a problem in
    xstream JettisonMappedXmlDriver used in XStreamExecutionContextStringSerializer

    I did a simple test to check the same.

    Map data = new HashMap();
    data.put("key1", "value");
    data.put("key3", "value");
    data.put("key2", "value");
    XStream xstream = new XStream(new JettisonMappedXmlDriver());
    String op = xstream.toXML(data);
    System.out.println(op);
    System.out.println(xstream.fromXML(op));

    o/p
    {"map":[{"entry":[{"string":["key3","value"]},{"string":["key2","value"]},{"string":["key1","value"]}]}]}
    Exception in thread "main" java.lang.InstantiationError: java.util.Map$Entry
    at sun.reflect.GeneratedSerializationConstructorAcces sor1.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Construc tor.java:513)
    at com.thoughtworks.xstream.converters.reflection.Sun 14ReflectionProvider.newInstance(Sun14ReflectionPr ovider.java:74)
    at com.thoughtworks.xstream.converters.reflection.Abs tractReflectionConverter.instantiateNewInstance(Ab stractReflectionConverter.java:308)
    at com.thoughtworks.xstream.converters.reflection.Abs tractReflectionConverter.unmarshal(AbstractReflect ionConverter.java:161)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.con vert(TreeUnmarshaller.java:82)
    at com.thoughtworks.xstream.core.AbstractReferenceUnm arshaller.convert(AbstractReferenceUnmarshaller.ja va:63)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.con vertAnother(TreeUnmarshaller.java:76)

    Whats the best workaround for this issue as of now.

    :Thanks

  • #2
    I don't think anyone else has seen this problem. Are you sure you have the correct version of XStream and/or Jettison on your classpath (as per the Spring Batch poms)?

    Comment


    • #3
      Thanks for the reply, I checked the spring batch pom
      <dependency>
      <groupId>com.thoughtworks.xstream</groupId>
      <artifactId>xstream</artifactId>
      </dependency>
      <dependency>
      <groupId>org.codehaus.jettison</groupId>
      <artifactId>jettison</artifactId>
      </dependency>
      It doesn't mentions any version number explicitly .So, I have xstream 1.3.1 and jettision 1.3 version respectively.

      I guess the issue was with JettisonMappedXmlDriver , when I tried with other xml drivers(XppDriver) it works. Unfortunately ,
      I couldn't find any way in spring batch to use a different driver. Not sure if I am missing anything else here.

      Comment


      • #4
        I think you need to make that jettison 1.1 (as specified in the parent pom for Spring Batch, if I recall correctly). You aren't missing anything else, except that if you want to you can implement the DAOs for a different version of jettison and create the JobRepository as a bean definition.

        Comment


        • #5
          It works with jettison 1.1 version . There is an issue with 1.3 version and doesn't makes sense to create custom dao and jobRepository just for this.
          On a different note it would be nice to have an option to set a different xmldriver for the dao's through factorybeans in the beans.xml file.
          Anyway , thanks for the help.

          Comment

          Working...
          X