shiro.session There is no session with id问题点排查

SSM+shiro+redis 做分布式项目时,在生产环境中遇到 org.apache.shiro.session.UnknownSessionException: There is no session with id

这个bug。排查了之后。问题点有以下两种:

(1):shiro的JSESSIONID 与Tomcat 、Jetty默认的JSESSIONID 冲突了。这时候需要改一下shiro对应的JSESSIONID:

<bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
   	 <property name="sessionDAO" ref="redisSessionService" />
	 <property name="sessionIdCookie" ref="sessionIdCookie"/>
     <property name="sessionValidationInterval" value="3600000"/>  <!-- 相隔多久检查一次session的有效性 -->  
	 <property name="globalSessionTimeout" value="3600000"/>  <!-- session 有效时间为半小时 (毫秒单位)-->  
	</bean>
	 <!--设置cookie-->
	 <!-- 会话Cookie模板 -->
    <bean id="sessionIdCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
        <constructor-arg value="sid"/>
        <!--设置Cookie名字,默认为JSESSIONID-->
        <property name="name" value="shiroUserid" />
		<property name="path" value="/"/>  
    </bean>

(2)排查redis的配置的maxmemory 是否设置有误:

# NOTE: since Redis uses the system paging file to allocate the heap memory,
# the Working Set memory usage showed by the Windows Task Manager or by other
# tools such as ProcessExplorer will not always be accurate. For example, right
# after a background save of the RDB or the AOF files, the working set value
# may drop significantly. In order to check the correct amount of memory used
# by the redis-server to store the data, use the INFO client command. The INFO
# command shows only the memory used to store the redis data, not the extra
# memory used by the Windows process for its own requirements. Th3 extra amount
# of memory not reported by the INFO command can be calculated subtracting the
# Peak Working Set reported by the Windows Task Manager and the used_memory_peak
# reported by the INFO command.
#
# maxmemory <bytes>
maxmemory 6000000000

我的生产环境是window Server 32G 的。原先配置的是32G的3/4 但这样设置每过一段时间就出现这样的bug。我假设内存是8G,配置了8G的3/4。就解决这个问题了

转载于:https://my.oschina.net/linwl/blog/1830698

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值