解决org.apache.shiro.session.UnknownSessionException: There is no session with id的问题
一、背景
最近在整合了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的问题的更多相关文章
- 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 ...
- shiro 不使用加密 解决 org.apache.shiro.authc.IncorrectCredentialsException: Submitted credentials for token [org.apache.sh
测试本方法为失效的 报错: org.apache.shiro.authc.IncorrectCredentialsException: Submitted credentials for token ...
- Apache Shiro 1.3.2入门
简介 Apache Shiro是一个功能强大且灵活的开放源代码安全框架,可以清楚地处理认证,授权,企业会话管理和加密.Apache Shiro的首要目标是易于使用和理解.有时候安全性可能非常复杂和痛苦 ...
- [转]在 Web 项目中应用 Apache Shiro
目录[-] 用户权限模型 图 1. 用户权限模型 认证与授权 Shiro 认证与授权处理过程 Shiro Realm 清单 1. 实现自己的 JDBC Realm 为何对 Shiro 情有独钟 与 S ...
- 在 Web 项目中应用 Apache Shiro
Apache Shiro 是功能强大并且容易集成的开源权限框架,它能够完成认证.授权.加密.会话管理等功能.认证和授权为权限控制的核心,简单来说,"认证"就是证明你是谁? Web ...
- Apache Shiro 开源权限框架
在 Web 项目中应用 Apache Shiro 开源权限框架 Apache Shiro 是功能强大并且容易集成的开源权限框架,它能够完成认证.授权.加密.会话管理等功能.认证和授权为权限控制的核心, ...
- Apache shiro集群实现 (六)分布式集群系统下的高可用session解决方案---Session共享
Apache shiro集群实现 (一) shiro入门介绍 Apache shiro集群实现 (二) shiro 的INI配置 Apache shiro集群实现 (三)shiro身份认证(Shiro ...
- Apache shiro集群实现 (八) web集群时session同步的3种方法
Apache shiro集群实现 (一) shiro入门介绍 Apache shiro集群实现 (二) shiro 的INI配置 Apache shiro集群实现 (三)shiro身份认证(Shiro ...
- Apache shiro集群实现 (五)分布式集群系统下的高可用session解决方案
Apache shiro集群实现 (一) shiro入门介绍 Apache shiro集群实现 (二) shiro 的INI配置 Apache shiro集群实现 (三)shiro身份认证(Shiro ...
随机推荐
- 成功解决在Python文件上右键菜单无“Edit with IDLE”选项
我电脑是Win7旗舰版,之前电脑上安装的是Python2.6版本的,前两天为了体验一下Microsoft Excel与Python之间互操作, 下载并安装了DataNitro,在安装的时候脑残的安装了 ...
- Remote Debugging (1)
The client/server design of the Java debugger allows you to launch a Java program from computer on y ...
- POJ3273--Monthly Expense(Binary Search)
Description Farmer John is an astounding accounting wizard and has realized he might run out of mone ...
- python_列表、元组、字典、集合对比
列表.元组.字典.集合 列表.元组.字典.集合对比 比较项 列表 元组 字典 集合 类型名称 list tuple dict set 定界符 [] () {} {} 是否可变 是 否 是 是 是否有序 ...
- Maven中的配置文件
<span style="padding:0px; margin:0px"><project xmlns="http://maven.apache.or ...
- [FAILED]Marking disk "DATA02" as an ASM disk
执行删除asm磁盘时报错! [root@rac1 grid]# /etc/init.d/oracleasm deletedisk DATA01 /dev/sdc1 Marking disk " ...
- Cerebro_变量名搜索插件
Cerebro 安装 兼容环境:Windows, MacOS, Linux 插件依赖于 Cerebro,下载地址: https://github.com/KELiON/cerebro/releases ...
- unigui导出EXCEL使用NATIVEEXCEL
unigui导出EXCEL使用NATIVEEXCEL // 需要nativeexcel控件// cxg 2017-9-9 unit myExcel; interface uses System.Sys ...
- 我的ecshop二次开发经验分享
https://jingyan.baidu.com/article/358570f65dbad2ce4724fcc7.html
- iOS证书说明和发布
1.首先通过钥匙串访问——证书助理——从证书颁发机构请求证书——填写证书信息(邮箱,常用名称,存储到磁盘)——存储为(自定义名称.certSigningReuqest,简称CSR文件,只是为了提交到苹 ...