一、背景

  最近在整合了Spring+Shiro+Redis实现tomcat集群session共享的问题之后,发布以后运行以后发现老是会出现:org.apache.shiro.session.UnknownSessionException: There is no session with id [xxxx]的问题,具体问题如下截图:

二、出现这个问题的原因

  只所以出现这个问题是因为在shiro的DefaultWebSessionManager类中,默认Cookie名称是JSESSIONID,这样的话与servlet容器名冲突, 如jetty, tomcat等默认JSESSIONID, 当跳出shiro servlet时如error-page容器会为JSESSIONID重新分配值导致登录会话丢失!

  明白了出现这个问题的原因,就好办了,我们只需要自己指定一个与项目运行容器不冲突的sessionID就好了,具体如下,在spring-shiro.xml中进行如下配置:

 <!--sessionManager -->
<bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
<property name="sessionDAO" ref="redisSessionDAO" />
<property name="sessionIdCookie" ref="simpleCookie"/>
</bean> <bean id="simpleCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
<constructor-arg name="name" value="shiro.sesssion"/>
<property name="path" value="/"/>
</bean>

这样,我们就很完美的解决了这个问题!至于想知道spring+shiro+redis集成实现tomcat集群session共享的童鞋,请移步:Shrio+Redis实现tomcat集群共享session

解决org.apache.shiro.session.UnknownSessionException: There is no session with id的问题的更多相关文章

  1. org.apache.shiro.session.UnknownSessionException: There is no session with id [xxxx]的解决方案

    org.apache.shiro.session.UnknownSessionException: There is no session with id [xxxx]的解决方案 背景描述 Sprin ...

  2. shiro 不使用加密 解决 org.apache.shiro.authc.IncorrectCredentialsException: Submitted credentials for token [org.apache.sh

    测试本方法为失效的 报错: org.apache.shiro.authc.IncorrectCredentialsException: Submitted credentials for token ...

  3. Apache Shiro 1.3.2入门

    简介 Apache Shiro是一个功能强大且灵活的开放源代码安全框架,可以清楚地处理认证,授权,企业会话管理和加密.Apache Shiro的首要目标是易于使用和理解.有时候安全性可能非常复杂和痛苦 ...

  4. [转]在 Web 项目中应用 Apache Shiro

    目录[-] 用户权限模型 图 1. 用户权限模型 认证与授权 Shiro 认证与授权处理过程 Shiro Realm 清单 1. 实现自己的 JDBC Realm 为何对 Shiro 情有独钟 与 S ...

  5. 在 Web 项目中应用 Apache Shiro

    Apache Shiro 是功能强大并且容易集成的开源权限框架,它能够完成认证.授权.加密.会话管理等功能.认证和授权为权限控制的核心,简单来说,"认证"就是证明你是谁? Web ...

  6. Apache Shiro 开源权限框架

    在 Web 项目中应用 Apache Shiro 开源权限框架 Apache Shiro 是功能强大并且容易集成的开源权限框架,它能够完成认证.授权.加密.会话管理等功能.认证和授权为权限控制的核心, ...

  7. Apache shiro集群实现 (六)分布式集群系统下的高可用session解决方案---Session共享

    Apache shiro集群实现 (一) shiro入门介绍 Apache shiro集群实现 (二) shiro 的INI配置 Apache shiro集群实现 (三)shiro身份认证(Shiro ...

  8. Apache shiro集群实现 (八) web集群时session同步的3种方法

    Apache shiro集群实现 (一) shiro入门介绍 Apache shiro集群实现 (二) shiro 的INI配置 Apache shiro集群实现 (三)shiro身份认证(Shiro ...

  9. Apache shiro集群实现 (五)分布式集群系统下的高可用session解决方案

    Apache shiro集群实现 (一) shiro入门介绍 Apache shiro集群实现 (二) shiro 的INI配置 Apache shiro集群实现 (三)shiro身份认证(Shiro ...

随机推荐

  1. 20170831工作日记--自定义View学习

    学习了LayoutInflater的原理分析.视图的绘制流程.视图的状态及重绘等知识,按类型来划分的话,自定义View的实现方式大概可以分为三种,自绘控件.组合控件.以及继承控件.那么下面我们就来依次 ...

  2. linux 修改ip 地址

    1./etc/sysconfig/network-scripts/ifcfg-网卡 如果是新网卡 自己写配置文档 ip a 即可查看网卡名字 (这是eno16777736) BOOTPROTO= dh ...

  3. redmine 开机自动运行

    想要redmine在centos上开机自动运行,于是就在 /etc/rc.local里面加上了一行脚本 #!/bin/shecho "start redmine:"/usr/loc ...

  4. web-day2

    第2章WEB02-CSS&JS篇 今日任务 使用CSS完成网站首页的美化 使用CSS完成网站注册页面的美化 使用JS完成简单的数据校验 使用JS完成图片轮播效果 教学导航 教学目标 了解CSS ...

  5. CALayer-CAShapeLayer/CAGradientLayer

    参考博客 CAShapeLayer http://blog.csdn.net/yongyinmg/article/details/38755955 CAShapeLayer和CAGradientLay ...

  6. poj 1753 2965

    这两道题类似,前者翻转上下左右相邻的棋子,使得棋子同为黑或者同为白.后者翻转同行同列的所有开关,使得开关全被打开. poj 1753 题意:有一4x4棋盘,上面有16枚双面棋子(一面为黑,一面为白), ...

  7. C++ const方法及对象

    一.整体代码 01.cpp #include <iostream> using namespace std; class Test { public: Test(int x) : x_(x ...

  8. MFC中处理UI界面时的注意点

    最近开发时,在处理界面上遇到了下面的问题: 上位机与下位机通信时,如果出现超时,弹出MessageBox提示的情况下,更新界面上的CStatic控件会出现重影. 经过调查发现 原因是由于在UI线程中处 ...

  9. ElementTriArgyris

    class ElementTriArgyris(ElementH2): nodal_dofs = 6 facet_dofs = 1 dim = 2 maxdeg = 5 def gdof(self, ...

  10. 计算日期差(Python实现)

    class Solution: def Days(self,year,month,day): if (year%4==0 and year%100!=0) or year%400==0: monthl ...