1

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

stefanglase
  • 9,652
  • 4
  • 29
  • 41
Srinath
  • 1,133
  • 3
  • 14
  • 25

1 Answers1

4

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.

stefanglase
  • 9,652
  • 4
  • 29
  • 41
  • Hi codescape, Mybad. Could you please provide me some sample code to avoid these errors . thanks. – Srinath Jun 21 '10 at 04:03
  • @Srinath: Added links with further information to java.io.Serializable and how to implement serializable classes in my answer. – stefanglase Jun 21 '10 at 06:32