无法为会话序列化会话属性SPRING_SECURITY_CONTEXT

时间:2014-09-17 07:27:41

标签: java session spring-security redis tomcat6

环境:Tomcat 6,Java 6,Redis和spring security-3.1.4

我尝试通过向Redis缓存添加用户会话来集群tomcat。我已将tomcat-redis-session-manager-1.2-tomcat-6.jar和jedis-2.0.0.jar复制到tomcat lib,并将下面的config添加到tomcat context.xml。

一切正常。但是当我尝试登录系统时,我会收到以下异常。

似乎有一个spring security context属性,它包含非serializable属性。请帮助解决此问题。

context.xml中

 <Valve className="com.radiadesign.catalina.session.RedisSessionHandlerValve" />
 <Manager className="com.radiadesign.catalina.session.RedisSessionManager"
     host="127.0.0.1"
     port="6379"
     database="0"
     maxInactiveInterval="60" />



   org.apache.catalina.session.StandardSession writeObject
   WARNING: Cannot serialize session attribute SPRING_SECURITY_CONTEXT for session    DDB4A51B19CF042B227E312B546483EF
java.io.NotSerializableException: java.util.HashMap$KeySet
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1561)
at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:1004)
at com.radiadesign.catalina.session.JavaSerializer.serializeFrom(JavaSerializer.java:24)
at com.radiadesign.catalina.session.RedisSessionManager.save(RedisSessionManager.java:411)
at com.radiadesign.catalina.session.RedisSessionHandlerValve.storeOrRemoveSession(RedisSessionHandlerValve.java:39)
at com.radiadesign.catalina.session.RedisSessionHandlerValve.invoke(RedisSessionHandlerValve.java:27)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:554)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:636)

1 个答案:

答案 0 :(得分:4)

CustomUserDetails类中有一个非序列化属性。