Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: java.io.NotSerializableException on transition on-exception

  1. #1
    Join Date
    May 2007
    Posts
    9

    Default 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:

    org.springframework.binding.method.MethodSignature
    org.springframework.binding.method.Parameters
    org.springframework.binding.method.Parameter
    org.springframework.binding.expression.support.Ogn lExpression

    Do you have any suggestions?

    Christian

  2. #2

    Default

    Can you paste the code of the flow in which this occures?

  3. #3
    Join Date
    May 2007
    Posts
    9

    Default

    Yes,

    Class MergeNotSupportedException extends RuntimeException

    <action-state id="mergeSection">
    <bean-action bean="sectionService" method="merge">
    <method-arguments>
    <argument expression="${requestParameters.elementId}" parameter-type="long" />
    </method-arguments>
    </bean-action>
    <transition on="success" to="manageElement" />
    <transition on-exception="it.smit.service.exception.MergeNotSuppo rtedException" to="listElement" />
    </action-state>

  4. #4

    Default

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

  5. #5
    Join Date
    May 2007
    Posts
    9

    Default

    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.

    If you read at this link:

    http://opensource.atlassian.com/proj...browse/SWF-269

    you can notice that from 1.02 version was introduced a new feature which resolves transitions dynamically when an on-exception occurs.

    I suppose that this new feature might be the cause of this problem.

    Do you think so?

    Christian

  6. #6
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    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.

    Also look at this issue:
    http://opensource.atlassian.com/proj...browse/SWF-280

    Erwin
    Last edited by klr8; May 4th, 2007 at 02:25 AM.

  7. #7
    Join Date
    May 2007
    Posts
    9

    Default

    Hi,
    I have created an example modifying the birthdate example:

    Service interface
    -------------------------------------
    package org.springframework.webflow.samples.birthdate.serv ice;

    public interface ServiceBean {
    void testIt();
    }
    --------------------------------------
    Service Exception

    ---------------------------------------
    package org.springframework.webflow.samples.birthdate.serv ice.exception;

    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>

    <action-state id="errorExample">
    <bean-action bean="serviceBean" method="testIt">
    </bean-action>
    <transition on="success" to="processBirthdateFormSubmit" />
    <transition on-exception="org.springframework.webflow.samples.bir thdate.service.exception.MyGeneratedException" to="processBirthdateFormSubmit" />
    </action-state>

    -------------------------------------------
    I have posted the src example folder.


    Christian
    Attached Files Attached Files

  8. #8
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    I'll take a look at this and report back.

    Erwin

  9. #9
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    Okay, I was able to reproduce and resolve the problem.

    The problem was that MethodInvocationException was holding on to objects that were not serializable, for instance MethodSignature.

    I've committed fixes for both 1.0.4 and 1.1 that make these non-serializable fields transient.

    Grab the next nightly build and give that a try:
    http://static.springframework.org/do...hp?project=SWF

    Erwin

  10. #10
    Join Date
    May 2006
    Posts
    25

    Default for those of us using 1.0.2

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •