title: Terracotta Web Sessions JDBC Datasource not Serializable
body: <p>I've been working on integrating Terracotta web sessions into our application architechture. Everything is correctly running and talking properly, however the application servers keep throwing a huge exception. Basically it is saying the JDBC connector (which hits a mysql db) isn't serializable (<code>java.io.NotSerializableException: org.apache.tomcat.jdbc.pool.DataSource</code>). </p>
  
  <p>We are using a pooled JNDI connector, and I switched to a basic JNDI connector and still got the issue. </p>
  
  <p>Here's our resources: Grails 2.04 hosted on Tomcat 7, Mysql, and the latest version of Terracotta.</p>
  
  <p>Edit: Added session inspect output
  Here is the output from <code>session.inspect ()</code>:</p>
  
  <pre><code> Session Content:
     javamelody.remoteAddr = 0:0:0:0:0:0:0:1%0
         SPRING_SECURITY_CONTEXT = org.springframework.security.core.context.SecurityContextImpl@f140e22a: Authentication: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@f140e22a: Principal: org.codehaus.groovy.grails.plugins.springsecurity.GrailsUser@b56ac240: Username: test@gmail.com; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@166c8: RemoteIpAddress: 0:0:0:0:0:0:0:1%0; SessionId: 837DF793887F57E6F0563708346A9EE1; Granted Authorities: ROLE_USER
     org.codehaus.groovy.grails.FLASH_SCOPE = org.codehaus.groovy.grails.web.servlet.GrailsFlashScope@58e83637
     javamelody.country = US
     javamelody.sessionActivation = SessionListener[sessionCount=1]
     emailServersService = proxyTargetClass=true; optimize=false; opaque=false; exposeProxy=false; frozen=false
     org.springframework.web.context.request.ServletRequestAttributes.DESTRUCTION_CALLBACK.(inner bean) =    org.springframework.web.context.request.DestructionCallbackBindingListener@753f827a
     grails-resources.debug-timestamp = 1349195096775
     javamelody.remoteUser = test@gmail.com
     org.springframework.web.context.request.ServletRequestAttributes.DESTRUCTION_CALLBACK.emailServersService = org.springframework.web.context.request.DestructionCallbackBindingListener@1c8f53b9
  </code></pre>
  
  <p>Edit 2: 
  After following Burt's advice, the session listener dumped out these attribute names (along with some lengthy stack traces), but again there is no mention of the datasource.</p>
  
  <pre><code> java.lang.Exception: attribute added: SPRING_SECURITY_LAST_USERNAME
   java.lang.Exception: attribute added: org.openid4java.discovery.DiscoveryInformation
   java.lang.Exception: attribute added: org.codehaus.groovy.grails.FLASH_SCOPE
   java.lang.Exception: attribute added: SPRING_SECURITY_CONTEXT
   2012-10-02 14:17:37,827 [http-bio-8080-exec-9] DEBUG mail.EmailServersService  - Initialization of new EmailServersService
   java.lang.Exception: attribute added: org.springframework.web.context.request.ServletRequestAttributes.DESTRUCTION_CALLBACK.(inner bean)
  </code></pre>
  
  <p>Now the listener doesn't fire before the not serializable error comes up.</p>