CAS 集群 redis问题

J2EE 码拜 9年前 (2016-05-12) 2482次浏览
最近做CAS集群,使用的是CAS 3.5.2和tomcat redis session manager 7,commons-pool 1.6,jdk7,jedis 2.2,看网上说在tomcat中配置tomcat redis session magager就能做到session共享,也做了ticket的redis存放改造。在默认情况下(用户名和密码相同)能够登陆成功,但是假如输入不相同的用户名和密码(为了验证错误登陆提示),第一次提示,您输入的凭证有误。再次输入不相同的用户名和密码,就无提示。后台报错如下:2015-01-19 17:20:26,087 DEBUG [org.springframework.web.servlet.DispatcherServlet] – <DispatcherServlet with name “cas” processing POST request for [/cas/login]>
2015-01-19 17:20:26,087 DEBUG [org.springframework.webflow.mvc.servlet.FlowHandlerMapping] – <Mapping request with URI “/cas/login” to flow with id “login”>
2015-01-19 17:20:26,088 DEBUG [org.springframework.webflow.executor.FlowExecutorImpl] – <Resuming flow execution with key “e1s2>
2015-01-19 17:20:26,089 DEBUG [org.springframework.webflow.conversation.impl.SessionBindingConversationManager] – <Locking conversation 1>
2015-01-19 17:20:26,089 DEBUG [org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository] – <Getting flow execution with key “e1s2”>
2015-01-19 17:20:26,090 DEBUG [org.springframework.webflow.conversation.impl.SessionBindingConversationManager] – <Unlocking conversation 1>
2015-01-19 17:20:26,092 DEBUG [org.jasig.cas.web.FlowExecutionExceptionResolver] – <Error getting flow information for URL [/cas/login?service=http%3A%2F%2F192.168.100.24%3A38080%2Fexamples%2Fservlets%2Fservlet%2FHelloWorldExample]>
org.springframework.webflow.execution.repository.FlowExecutionRestorationFailureException: A problem occurred restoring the flow execution with key “e1s2”
at org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository.getFlowExecution(DefaultFlowExecutionRepository.java:113)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:168)
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.jasig.cas.web.init.SafeDispatcherServlet.service_aroundBody2(SafeDispatcherServlet.java:128)
at org.jasig.cas.web.init.SafeDispatcherServlet.service_aroundBody3$advice(SafeDispatcherServlet.java:57)
at org.jasig.cas.web.init.SafeDispatcherServlet.service(SafeDispatcherServlet.java:1)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.github.inspektr.common.web.ClientInfoThreadLocalFilter.doFilter(ClientInfoThreadLocalFilter.java:63)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at com.radiadesign.catalina.session.RedisSessionHandlerValve.invoke(RedisSessionHandlerValve.java:26)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.webflow.execution.repository.snapshot.SnapshotNotFoundException: No flow execution snapshot could be found with id “2”; perhaps the snapshot has been removed?
at org.springframework.webflow.execution.repository.impl.SimpleFlowExecutionSnapshotGroup.getSnapshot(SimpleFlowExecutionSnapshotGroup.java:74)
at org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository.getFlowExecution(DefaultFlowExecutionRepository.java:111)
… 41 more
说是流程‘id=2’快照找不到。就算输入正确的用户名和密码也登陆不了。假如把tomcat-redis-session-manager配置去掉。重新启动,重复3次输入不同用户名和密码,后台不会报错。都能正确提示您提供的凭证有误。输入相同的用户名和密码,也能登陆成功。现在的问题是,是不是tomcat-redis-session-manager有问题。本人试过jdk1.6, tomcat-redis-session-manager-6,也不行。请各位做过CAS集群的大牛帮忙分析分析。救小弟于水深火热之中啊。感谢。
解决方案

100

spring web flow里面跟session进行了绑定操作,conversation这个对象里面存在的对象,嵌套了很多对象,跟session进行绑定的时候直接从session中获取conversation,然后直接修改了conversation之后没有将conversation对象再回放到session中,
所以假如session的实现类是操作jvm的内存的话是没有问题,原因是取出来之后直接修改就是修改的最真实的对象。但是你的方案是将session中的值都存在redis中,webFlow代码中很多地方都是直接从session中取值然后进行修改,最终无法体现到redis中,所以会出现各种问题,建议你换种方案。
你的最终方案是什么可以拿出来共享一下,大家研究一下

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明CAS 集群 redis问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)