shiro执行logout的时候提示session不存在

黄文祥 发布于 2013/03/01 15:32
阅读 9K+
收藏 0

在用户登录系统之后,进行执行logout的操作时候出现异常,session不存在 大家有见过吗?

logout的controller代码:

@RequestMapping(value = "/loginout")
    public String loginOut()
    {
        Subject currentUser = SecurityUtils.getSubject();
        if (SecurityUtils.getSubject().getSession() != null)
        {
            currentUser.logout();
        }
        return "login";
    }

2013-3-1 15:24:51 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [frameworkServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: org.apache.shiro.session.UnknownSessionException: There is no session with id [24c4d39e-34b0-424b-b9b3-63e89c44b87c]] with root cause
org.apache.shiro.session.UnknownSessionException: There is no session with id [24c4d39e-34b0-424b-b9b3-63e89c44b87c]
	at org.apache.shiro.session.mgt.eis.AbstractSessionDAO.readSession(AbstractSessionDAO.java:170)
	at org.apache.shiro.session.mgt.DefaultSessionManager.retrieveSessionFromDataSource(DefaultSessionManager.java:236)
	at org.apache.shiro.session.mgt.DefaultSessionManager.retrieveSession(DefaultSessionManager.java:222)
	at org.apache.shiro.session.mgt.AbstractValidatingSessionManager.doGetSession(AbstractValidatingSessionManager.java:118)
	at org.apache.shiro.session.mgt.AbstractNativeSessionManager.lookupSession(AbstractNativeSessionManager.java:105)
	at org.apache.shiro.session.mgt.AbstractNativeSessionManager.lookupRequiredSession(AbstractNativeSessionManager.java:109)
	at org.apache.shiro.session.mgt.AbstractNativeSessionManager.getAttribute(AbstractNativeSessionManager.java:206)
	at org.apache.shiro.session.mgt.DelegatingSession.getAttribute(DelegatingSession.java:141)
	at org.apache.shiro.session.ProxiedSession.getAttribute(ProxiedSession.java:121)
	at org.apache.shiro.web.servlet.ShiroHttpSession.getAttribute(ShiroHttpSession.java:131)
	at org.springframework.web.util.WebUtils.getSessionAttribute(WebUtils.java:266)
	at org.springframework.web.servlet.i18n.SessionLocaleResolver.resolveLocale(SessionLocaleResolver.java:56)
	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1131)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:927)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:380)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	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:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:185)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:269)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)

加载中
0
黄文祥
黄文祥
知道是什么问题了,执行logout其实不需要自己手动来处理,直接由shiro自行处理就可以了。
JackFace
JackFace
具体点。
Invincible_JM
Invincible_JM
怎么解决的??
0
戒烟戒酒戒基友
你好,我刚开始学习shiro 。你也用的springMVC+shiro么?我的前台页面是extjs  现在对shiro还是有些模糊,能跟你交流交流么?我的qq是601786076,谢谢。
戒烟戒酒戒基友
回复 @huangwenxiang : 我现在登录的认证是做好了。不过怎么授权我就比较郁闷了。
h
huangwenxiang
官方文档有很多入门的demo,看看入门没什么问题的,慢慢的去延伸吧
0
t
tianlanjingwen
请问 这问题 解决了吗
h
huangwenxiang
还没有哦 ,最近在忙项目 没空弄,你先去看看啥问题 弄好了说下啊
0
t
tianlanjingwen
我也遇见此问题了  谢谢
0
山头的兄弟

是不是你设置的时间太短  其实用户已经退出了

你加了判断 直接跟

else

{System.out.println("超时了,已经退出");

}

h
huangwenxiang
超时 肯定是不可能的,默认是30分钟,再说这个退出也是测试 登录之后立刻点按钮退出操作的
返回顶部
顶部