Technipelago AB

Technipelago Blog Stuff that we learned...


Serialize domain objects in Grails Web Flow

Publicerad den 15 sep 2008

If you are using Grails Web Flow and put domain object in flash scope.


flash.model = new MyModel()

Make sure your events beforeInsert, beforeUpdate, beforeDelete, etc. are marked transient. Otherwise the domain object cannot be serialized and you get the following exception:



Could not serialize flow execution; make sure all objects stored in flow or flash scope are serializable; nested exception is java.io.NotSerializableException
 

This happens because closures cannot be serialized.

Always mark your closues as transient to avoid future serialization problems.


class MyModel implements java.io.Serializable {

transient def beforeInsert = { … }

}

Tags: grails


« Tillbaka