【问题标题】:Terracotta Web Sessions JDBC Datasource not SerializableTerracotta Web 会话 JDBC 数据源不可序列化
【发布时间】:2012-09-30 18:25:01
【问题描述】:

我一直致力于将 Terracotta 网络会话集成到我们的应用程序架构中。一切都正常运行并正常通信,但是应用程序服务器不断抛出一个巨大的异常。基本上它是说 JDBC 连接器(访问 mysql 数据库)不可序列化(java.io.NotSerializableException: org.apache.tomcat.jdbc.pool.DataSource)。

我们正在使用池化 JNDI 连接器,我切换到基本 JNDI 连接器,但问题仍然存在。

这是我们的资源:托管在 Tomcat 7、Mysql 和最新版本的 Terracotta 上的 Grails 2.04。

编辑:添加会话检查输出 这是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

编辑 2: 在听从 Burt 的建议后,会话侦听器转储了这些属性名称(以及一些冗长的堆栈跟踪),但同样没有提及数据源。

 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)

现在监听器在出现不可序列化错误之前不会触发。

【问题讨论】:

  • 我没有明确地把它放在任何地方。我知道绝对不应该这样。
  • Burt,我添加了对会话对象的检查,因为我认为没有提到 org.apache.tomcat.jdbc.pool.DataSource。有什么想法可以继续寻找吗?
  • 尝试创建一个 javax.servlet.http.HttpSessionAttributeListener 实例并将其注册为 web.xml 中的 <listener> - 您可以通过将 new Exception("attribute added").printStackTrace() 放入 attributeAdded 来查看它的添加位置方法
  • @BurtBeckwith 它看起来不像在可序列化错误弹出之前触发了侦听器。

标签: tomcat grails jdbc terracotta


【解决方案1】:

我通过删除我标记为会话范围的服务解决了这个问题。在这项服务中,我什至没有与 jdbc 数据源进行交互,所以我真的不知道发生了什么。

希望如果其他人遇到这个问题,他们可以使用服务范围来弄清楚他们的实例发生了什么。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-09
    • 2019-06-17
    • 1970-01-01
    • 2015-03-31
    相关资源
    最近更新 更多