2013-10-09 1 views
1

jsf 프로젝트를 Spring Webflow + JSF로 마이그레이션하려고합니다. ehcache를 사용하여 채팅 및 사용자 데이터에 대한 정보를 저장합니다. Dpwb 클래스 (serialize 된)는 ehcache에서 데이터를 가져옵니다. Dpwb 클래스가 직렬화 될수록 제대로 동작 할 것입니다. 왜 ehcache를 직렬화 할 것인가에 대해서는 아무 것도 할 수 없습니다.java.io.NotSerializableException : Spring Webflow 프로젝트의 net.sf.ehcache.Cache

flow.xml

<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"> 

    <var name="wbIdentifiers" class="com.emyed.whiteboard.controller.WhiteboardIdentifiers" /> 
    <view-state id="createWb" view="createdialog.xhtml"> 
     <transition on="create" to="wboard"> 
      <evaluate expression="generalCreateWhiteboard.create()" 
       result="wbIdentifiers" /> 
     </transition> 
    </view-state> 


    <view-state id="wboard" view="/WEB-INF/views/D/whiteboard.xhtml"> 
     <on-render> 
      <evaluate expression="generalCreateWhiteboard.setDisplayWhiteboard(wbIdentifiers)" result="viewScope.dpwb "></evaluate> 
     </on-render> 
    </view-state> 

</flow> 

예외

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.<init>(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.<init>(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) 

답변

2

예외가 WebFlow 직렬화하려고하는 물체의 하나의 인스턴스 변수를 갖는다 (또는 그와 다른 오브젝트를 포함 함을 나타낸다 인스턴스 변수)의 형식을 net.sf.ehcache.Cache로 지정합니다.이 형식은 직렬화 할 수 없습니다. 객체를 java.io.Serializable으로 표시하는 것만으로는 충분하지 않으며, 직렬화 된 모든 멤버도 직렬화 가능해야합니다. 당신 플로우 정의에서

how to test in Java that a class implements Serializable correctly (not just is an instance of Serializable)

, 그것을 :

이 질문은 당신이 뭔가 정말 직렬화 여부를 확인하는 데 사용할 수있는 테스트 (인스턴스 변수는 의미로 시험에 채워야합니다) 설명 com.emyed.whiteboard.controller.WhiteboardIdentifiers은 흐름 범위에 저장되어 있기 때문에 직렬화가 가능해야합니다.

"Dpwb"클래스는 직렬화 할 필요가없는보기 범위에만 저장되기 때문에 "Dpwb"클래스는 직렬화 할 수 있어야합니다.