0

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 (java.io.NotSerializableException: org.apache.tomcat.jdbc.pool.DataSource).

We are using a pooled JNDI connector, and I switched to a basic JNDI connector and still got the issue.

Here's our resources: Grails 2.04 hosted on Tomcat 7, Mysql, and the latest version of Terracotta.

Edit: Added session inspect output Here is the output from session.inspect ():

 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

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.

 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)

Now the listener doesn't fire before the not serializable error comes up.

Michael Dillon
  • 1,037
  • 6
  • 16
  • I'm not explicitly putting it in, anywhere. Which I understand it should definitely not be. – Michael Dillon Sep 30 '12 at 19:02
  • Burt, I added a inspection of the session object, and as I thought there isn't any mention of `org.apache.tomcat.jdbc.pool.DataSource`. Any thoughts on where to keep looking? – Michael Dillon Oct 02 '12 at 16:48
  • Try creating an instance of javax.servlet.http.HttpSessionAttributeListener and registering it as a `` in web.xml - you can see where it's being added by putting `new Exception("attribute added").printStackTrace()` in the `attributeAdded` method – Burt Beckwith Oct 02 '12 at 17:29
  • @BurtBeckwith it doesn't look like the listener is fired before the serializable error pops up. – Michael Dillon Oct 02 '12 at 20:08

1 Answers1

1

I solved this issue by removing a service that I had marked for session scoping. Nowhere in this service was I even interacting with the jdbc datasource so I don't really know what was going on.

Hopefully if anyone else runs into this issue they can play with the service scoping to figure out whats going on with their instance.

Michael Dillon
  • 1,037
  • 6
  • 16