java.io.NotSerializableException on transition on-exception
Dear All,
I have noticed that using spring web-flow (>= 1.02 version) on transitions which
have the tag "transition on-exception" this exception occurs:
10:00:50,015 ERROR [DispatcherPortlet] Could not complete request
org.springframework.webflow.execution.repository.c ontinuation.ContinuationCreationException: Could not serialize flow execution; make sure all objects stored in flow or flash scope are serializable; nested exception is java.io.NotSerializableException: org.springframework.binding.method.MethodSignature
Caused by:
java.io.NotSerializableException: org.springframework.binding.method.MethodSignature
at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1081)
at java.io.ObjectOutputStream.defaultWriteFields(Obje ctOutputStream.java:1375)
at java.io.ObjectOutputStream.writeSerialData(ObjectO utputStream.java:1347)
at java.io.ObjectOutputStream.writeOrdinaryObject(Obj ectOutputStream.java:1290)
at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1079)
at java.io.ObjectOutputStream.defaultWriteFields(Obje ctOutputStream.java:1375)
at java.io.ObjectOutputStream.writeSerialData(ObjectO utputStream.java:1347)
at java.io.ObjectOutputStream.writeOrdinaryObject(Obj ectOutputStream.java:1290)
at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1079)
at java.io.ObjectOutputStream.writeObject(ObjectOutpu tStream.java:302)
at java.util.HashMap.writeObject(HashMap.java:1039)
at sun.reflect.GeneratedMethodAccessor84.invoke(Unkno wn Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at java.io.ObjectStreamClass.invokeWriteObject(Object StreamClass.java:917)
at java.io.ObjectOutputStream.writeSerialData(ObjectO utputStream.java:1339)
at java.io.ObjectOutputStream.writeOrdinaryObject(Obj ectOutputStream.java:1290)
at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1079)
at java.io.ObjectOutputStream.defaultWriteFields(Obje ctOutputStream.java:1375)
at java.io.ObjectOutputStream.defaultWriteObject(Obje ctOutputStream.java:391)
at org.springframework.webflow.core.collection.LocalA ttributeMap.writeObject(LocalAttributeMap.java:307 )
at sun.reflect.GeneratedMethodAccessor625.invoke(Unkn own Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at java.io.ObjectStreamClass.invokeWriteObject(Object StreamClass.java:917)
at java.io.ObjectOutputStream.writeSerialData(ObjectO utputStream.java:1339)
at java.io.ObjectOutputStream.writeOrdinaryObject(Obj ectOutputStream.java:1290)
at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1079)
at java.io.ObjectOutputStream.writeObject(ObjectOutpu tStream.java:302)
at org.springframework.webflow.engine.impl.FlowSessio nImpl.writeExternal(FlowSessionImpl.java:160)
at java.io.ObjectOutputStream.writeExternalData(Objec tOutputStream.java:1310)
at java.io.ObjectOutputStream.writeOrdinaryObject(Obj ectOutputStream.java:1288)
at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1079)
at java.io.ObjectOutputStream.writeObject(ObjectOutpu tStream.java:302)
at java.util.LinkedList.writeObject(LinkedList.java:7 55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at java.io.ObjectStreamClass.invokeWriteObject(Object StreamClass.java:917)
at java.io.ObjectOutputStream.writeSerialData(ObjectO utputStream.java:1339)
at java.io.ObjectOutputStream.writeOrdinaryObject(Obj ectOutputStream.java:1290)
at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1079)
at java.io.ObjectOutputStream.writeObject(ObjectOutpu tStream.java:302)
at org.springframework.webflow.engine.impl.FlowExecut ionImpl.writeExternal(FlowExecutionImpl.java:482)
at java.io.ObjectOutputStream.writeExternalData(Objec tOutputStream.java:1310)
at java.io.ObjectOutputStream.writeOrdinaryObject(Obj ectOutputStream.java:1288)
at java.io.ObjectOutputStream.writeObject0(ObjectOutp utStream.java:1079)
at java.io.ObjectOutputStream.writeObject(ObjectOutpu tStream.java:302)
at org.springframework.webflow.execution.repository.c ontinuation.SerializedFlowExecutionContinuation.se rialize(SerializedFlowExecutionContinuation.java:1 78)
at org.springframework.webflow.execution.repository.c ontinuation.SerializedFlowExecutionContinuation.<i nit>(SerializedFlowExecutionContinuation.java:70)
at org.springframework.webflow.execution.repository.c ontinuation.SerializedFlowExecutionContinuationFac tory.createContinuation(SerializedFlowExecutionCon tinuationFactory.java:55)
at org.springframework.webflow.execution.repository.c ontinuation.ContinuationFlowExecutionRepository.pu tFlowExecution(ContinuationFlowExecutionRepository .java:178)
at org.springframework.webflow.executor.FlowExecutorI mpl.resume(FlowExecutorImpl.java:249)
at org.springframework.webflow.executor.mvc.PortletFl owController.handleActionRequestInternal(PortletFl owController.java:193)
at org.springframework.web.portlet.mvc.AbstractContro ller.handleActionRequest(AbstractController.java:1 91)
at org.springframework.web.portlet.mvc.SimpleControll erHandlerAdapter.handleAction(SimpleControllerHand lerAdapter.java:46)
at org.springframework.web.portlet.DispatcherPortlet. doActionService(DispatcherPortlet.java:677)
at org.springframework.web.portlet.FrameworkPortlet.p rocessRequest(FrameworkPortlet.java:458)
at org.springframework.web.portlet.FrameworkPortlet.p rocessAction(FrameworkPortlet.java:440)
at com.liferay.portal.kernel.servlet.PortletServlet.s ervice(PortletServlet.java:88)
....
I have resolved this problem implementing Serializable interface for classes below:
Strange.. Does this error keep occuring when you remove the on-exception transition?
Implementing Serializable for the classes you mentioned isn't the right thing to do..
Hi,
I reckon that adding the Serializable interface to the previous classes isn't the real solution to the problem.
But, I would like to underline that it always happen when the type of transition is "on-exception" (and this doesn't happen using the 1.01 version).
Moreover, this behaviour doesn't happen in other transaction types.
Is your MergeNotSupportedException serializable?
Can you post the code of that exception?
Keep in mind that *all* Java exceptions should be serializable (Throwable implements Serializable), so you cannot have references to non-serializable objects from inside an exception!
The SWF TransitionExecutingStateExceptionHandler will put the exception it handles in flash scope, which could lead to this kind of problem.
public class MyGeneratedException extends RuntimeException{
private static final long serialVersionUID = 1L;
}
-------------------------------------
Service Implementation
-----------------------------------
package org.springframework.webflow.samples.birthdate.serv ice.impl;
import org.springframework.webflow.samples.birthdate.serv ice.ServiceBean;
import org.springframework.webflow.samples.birthdate.serv ice.exception.MyGeneratedException ;
-------------------------------------
public class ServiceBeanImpl implements ServiceBean{
public void testIt()
{
throw new MyGeneratedException ();
}
}
---------------------------
birthdate.xml
-------------------------------
<!-- Display the first input form view -->
<view-state id="enterBirthdate" view="birthdateForm">
<!--
Prepare to display a new form. Initializes the backing "form object" and installs property
editors to format form field values.
-->
<render-actions>
<action bean="formAction" method="setupForm" />
</render-actions>
<transition on="submit" to="errorExample" />
</view-state>
Howdy,
I'm experiencing the same error on 1.0.2. I don't want to switch to 1.0.4 because they use different vesions of spring and spring -binding. Can that fix be applied to 1.0.2 as well?
--jim