title: Spring Batch Serialization Problems with Java 8 time package
body: <p>I have a Spring-batch application that stores several Java 8 time objects in the JobExecutionContext.  I am using the default serializer for my JobRespository.  I am facing exceptions when parsing back out the data that is being written into the BATCH_STEP_EXECUTION_CONTEXT table.  I have a LocalDateTime that is being stored as:</p>
  
  <pre><code>{
      "@resolves-to": "java.time.Ser",
      "byte": [5,
      8,
      18,
      8,
      45,
      50],
      "int": [2015,
      10000000]
  }
  </code></pre>
  
  <p>This leads to an exception when I try to read from the previous JobExecution data:</p>
  
  <pre><code>Caused by: java.lang.ClassCastException: java.lang.Byte cannot be cast to java.lang.Integer
  at com.thoughtworks.xstream.core.util.CustomObjectInputStream.readInt(CustomObjectInputStream.java:144) ~[xstream-1.4.8.jar:1.4.8]
  at java.time.LocalDate.readExternal(LocalDate.java:2070) ~[na:1.8.0_45]
  at java.time.LocalDateTime.readExternal(LocalDateTime.java:2002) ~[na:1.8.0_45]
  at java.time.Ser.readInternal(Ser.java:259) ~[na:1.8.0_45]
  at java.time.Ser.readExternal(Ser.java:246) ~[na:1.8.0_45]
  at com.thoughtworks.xstream.converters.reflection.ExternalizableConverter.unmarshal(ExternalizableConverter.java:167) ~[xstream-1.4.8.jar:1.4.8]
  at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72) ~[xstream-1.4.8.jar:na]
  ... 97 common frames omitted
  </code></pre>
  
  <p>I am using Spring-batch 3.0.5.RELEASE.  I've also tried upgrading to the latest versions of xstream (1.4.8) and Jettison (1.3.7), but I get the same exception.</p>
  
  <p>This appears to be a known issue with XStream (<a href="https://github.com/x-stream/xstream/issues/24" rel="nofollow">link</a>).  The suggestion was to register a custom converter within XStream.  However, spring-batch does not expose the actual XStream object in order to register a converter.  Any suggestions on how to proceed?</p>