I have a Domain object that tracks the user that created, deleted and modified it using the injected Spring Security service, def springSecurityService
. Instances of these objects are saved in the session and in production the session is persisted to a database for session failover. The Jetty
session storage class serializes the objects in the session but throws an exception if the session contains an object that's not serializable which the springSecurityService
is not. Is there someway to mark the springSecurityService
instance as ignored, transient
may be, but still have access to the service
? I tried.
static transients = ['springSecurityService']
did not help.
Try using,
transient SpringSecurityService springSecurityService
static transients = ['springSecurityService']
The first statement tells Java, not to serialize; whereas the second tells Grails not to persist.
Note: Btw, injecting service in domain class is discouraged.