title: java.io.NotSerializableException: net.sf.ehcache.Cache in Spring Webflow project
body: <p>I'm migrating our jsf project to Spring Webflow + JSF. We use ehcache to store information about chat and users data. Dpwb class(serialized) pulls data from the ehcache. As long the Dpwb class is serialized it should work, why it is looking for serializing ehcache which I can't do anything about it. </p>
  
  <p><strong>flow.xml</strong></p>
  
  <pre><code>&lt;flow xmlns="http://www.springframework.org/schema/webflow"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/webflow
          http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"&gt;
  
      &lt;var name="wbIdentifiers" class="com.emyed.whiteboard.controller.WhiteboardIdentifiers" /&gt;
      &lt;view-state id="createWb" view="createdialog.xhtml"&gt;
          &lt;transition on="create" to="wboard"&gt;
              &lt;evaluate expression="generalCreateWhiteboard.create()"
                  result="wbIdentifiers" /&gt;
          &lt;/transition&gt;
      &lt;/view-state&gt;
  
  
      &lt;view-state id="wboard" view="/WEB-INF/views/D/whiteboard.xhtml"&gt;
          &lt;on-render&gt;
              &lt;evaluate expression="generalCreateWhiteboard.setDisplayWhiteboard(wbIdentifiers)"  result="viewScope.dpwb "&gt;&lt;/evaluate&gt;
          &lt;/on-render&gt;
      &lt;/view-state&gt;
  
  &lt;/flow&gt;
  </code></pre>
  
  <p><strong>Exception</strong></p>
  
  <pre><code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.webflow.execution.repository.snapshot.SnapshotCreationException: Could not serialize flow execution; make sure all objects stored in flow or flash scope are serializable
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:948)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  root cause
  
  org.springframework.webflow.execution.repository.snapshot.SnapshotCreationException: Could not serialize flow execution; make sure all objects stored in flow or flash scope are serializable
      org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshot.&lt;init&gt;(SerializedFlowExecutionSnapshot.java:75)
      org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshotFactory.createSnapshot(SerializedFlowExecutionSnapshotFactory.java:70)
      org.springframework.webflow.execution.repository.snapshot.AbstractSnapshottingFlowExecutionRepository.snapshot(AbstractSnapshottingFlowExecutionRepository.java:75)
      org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository.putFlowExecution(DefaultFlowExecutionRepository.java:126)
      org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:171)
      org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
      org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:48)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  root cause
  
  java.io.NotSerializableException: net.sf.ehcache.Cache
      java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
      java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
      java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
      java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
      java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
      java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
      java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
      java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
      java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
      java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
      java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
      java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
      java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
      java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
      java.util.HashMap.writeObject(HashMap.java:1001)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:597)
      java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
      java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469)
      java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
      java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
      java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
      java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:422)
      org.springframework.webflow.core.collection.LocalAttributeMap.writeObject(LocalAttributeMap.java:327)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:597)
      java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
      java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469)
      java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
      java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
      java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
      java.util.HashMap.writeObject(HashMap.java:1001)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:597)
      java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
      java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469)
      java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
      java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
      java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
      java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:422)
      org.springframework.webflow.core.collection.LocalAttributeMap.writeObject(LocalAttributeMap.java:327)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:597)
      java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
      java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469)
      java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
      java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
      java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
      org.springframework.webflow.engine.impl.FlowSessionImpl.writeExternal(FlowSessionImpl.java:160)
      java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1429)
      java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1398)
      java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
      java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
      java.util.LinkedList.writeObject(LinkedList.java:943)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:597)
      java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
      java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469)
      java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
      java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
      java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
      org.springframework.webflow.engine.impl.FlowExecutionImpl.writeExternal(FlowExecutionImpl.java:309)
      java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1429)
      java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1398)
      java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
      java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
      org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshot.serialize(SerializedFlowExecutionSnapshot.java:173)
      org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshot.&lt;init&gt;(SerializedFlowExecutionSnapshot.java:70)
      org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshotFactory.createSnapshot(SerializedFlowExecutionSnapshotFactory.java:70)
      org.springframework.webflow.execution.repository.snapshot.AbstractSnapshottingFlowExecutionRepository.snapshot(AbstractSnapshottingFlowExecutionRepository.java:75)
      org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository.putFlowExecution(DefaultFlowExecutionRepository.java:126)
      org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:171)
      org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
      org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:48)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  </code></pre>