首页 > 其他 > 详细

Shiro

时间:2021-06-04 12:12:07      阅读:15      评论:0      收藏:0      [点我收藏+]
Caused by: org.apache.shiro.session.UnknownSessionException: There is no session with id [55759cea-7274-4931-9c3e-bceb32ac297e]
	at org.apache.shiro.session.mgt.eis.AbstractSessionDAO.readSession(AbstractSessionDAO.java:170) ~[shiro-core-1.7.1.jar:1.7.1]

  通过API登录有时会报错【先登录一次,登录第二次就会报错,应该是把cookie带过去了】,比较奇怪,出现在

session.setAttribute(CmsUtils.SESSION_CONSOLE_USER,cmsUser);

  检查java代码:

    /**
     * Retrieves the Session object from the underlying EIS identified by <tt>sessionId</tt> by delegating to
     * the {@link #doReadSession(java.io.Serializable)} method.  If {@code null} is returned from that method, an
     * {@link UnknownSessionException} will be thrown.
     *
     * @param sessionId the id of the session to retrieve from the EIS.
     * @return the session identified by <tt>sessionId</tt> in the EIS.
     * @throws UnknownSessionException if the id specified does not correspond to any session in the EIS.
     */
    public Session readSession(Serializable sessionId) throws UnknownSessionException {
        Session s = doReadSession(sessionId);
        if (s == null) {
            throw new UnknownSessionException("There is no session with id [" + sessionId + "]");
        }
        return s;
    }

  

MemorySessionDAO的:
    protected Session doReadSession(Serializable sessionId) {
        return sessions.get(sessionId);
    }

  发现调用了N多次这个方法,可能还是使用Shiro的环节出现了问题。

修改login的代码,每次登录都重新构造subject,解决该问题,原因待查:

            Subject subject = null;//SecurityUtils.getSubject();
            if (subject == null) {
                subject = (new Subject.Builder()).buildSubject();
                ThreadContext.bind(subject);
            }

  

 

Shiro

原文:https://www.cnblogs.com/webjlwang/p/14848602.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!