views:

38

answers:

1

Hi, I was getting issue wen using new Sql method in grails .

import groovy.sql.Sql
def datasource    
def organization_config = new Sql(dataSource)
    def orgs = organization_config.rows("select o.organizationId,o.name from organization o ")
    session.setAttribute("org_results", orgs);

The application is running but getting these errors when restart tomcat server.

SEVERE: IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: groovy.sql.GroovyRowResult
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: groovy.sql.GroovyRowResult

Can any one please tell me wy this is coming .

thanks in advance, sri..

+1  A: 

Tomcat can persist session accress shutdowns and restarts if all your session objects implement java.io.Serializable. If session objects do not implement java.io.Serializable your session cannot survive a shutdown and restart. In your case objects of type groovy.sql.GroovyRowResult do not implement java.io.Serializable.

The message can be considered harmless in terms of functionality during uptime as long as you do not cluster multiple Tomcat instances to serve your application. In this case you really should implement this interface in every class your put into the session. Otherwise Tomcat cannot ship the sessions between multiple cluster nodes.

codescape
Hi codescape, Mybad. Could you please provide me some sample code to avoid these errors . thanks.
Srinath
@Srinath: Added links with further information to java.io.Serializable and how to implement serializable classes in my answer.
codescape
@codescape, thanks .
Srinath

related questions