shiro redis session共享問題

package com.zm.blog.config.shiro;java

import java.io.Serializable;redis

import javax.annotation.Resource;spring

import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.ValidatingSession;
import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;apache

import com.zm.blog.utils.shiroUtil.SerializableUtils;session

public class MySessionDao extends EnterpriseCacheSessionDAO {
    
    @Autowired
    private StringRedisTemplate stringRedisTemplate;app

    @Resource(name = "redisTemplate")
    ValueOperations<Object, Object> valOps;ide

    @Override
    protected Serializable doCreate(Session session) {
        Serializable sessionId = generateSessionId(session);
        System.out.println("MySessionDao.doCreate();"+sessionId);
        assignSessionId(session, sessionId);
        valOps.set(sessionId, SerializableUtils.serialize(session));
        return session.getId();
    }ui

    @Override
    protected Session doReadSession(Serializable sessionId) {
        System.out.println("MySessionDao.doReadSession();"+sessionId);
        /*if(valOps.get(sessionId).toString().isEmpty())
            return null;*/
        return SerializableUtils.deserialize(valOps.get("sessionId").toString());
    }url

    @Override
    protected void doUpdate(Session session) {
        System.out.println("MySessionDao.doUpdate();"+session.getId());
        if (session instanceof ValidatingSession && !((ValidatingSession) session).isValid()) {
            return;
        }
        valOps.set(session.getId(),SerializableUtils.serialize(session));
    }spa

    @Override
    protected void doDelete(Session session) {
        System.out.println("MySessionDao.doDelete();");
        stringRedisTemplate.delete(session.getId().toString());
    }
}
 

MySessionDao.doCreate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
onStart
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
本次《/blog/login;JSESSIONID=585054a5-e499-4d46-b277-90ac9934934f》請求的處理時間爲:0ms
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
2018-01-13 13:11:43.574 DEBUG 6152 --- [p-nio-80-exec-5] c.z.b.m.c.C.getUserByName                : ==>  Preparing: select * from t_user where username=? 
2018-01-13 13:11:43.574 DEBUG 6152 --- [p-nio-80-exec-5] c.z.b.m.c.C.getUserByName                : ==> Parameters: admin(String)
2018-01-13 13:11:43.587 DEBUG 6152 --- [p-nio-80-exec-5] c.z.b.m.c.C.getUserByName                : <==      Total: 1
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
本次《/blog/checkLogin》請求的處理時間爲:36ms
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
本次《/blog/》請求的處理時間爲:0ms
2018-01-13 13:11:43.642 DEBUG 6152 --- [p-nio-80-exec-8] c.z.b.m.c.CustomUserMapper.getUserRoles  : ==>  Preparing: SELECT r.id,ur.userid,r.rolename,r.remark,r.createdate,r.updatedate FROM t_role r LEFT JOIN t_userrole ur ON r.id=ur.roleid WHERE ur.userid=? 
2018-01-13 13:11:43.642 DEBUG 6152 --- [p-nio-80-exec-8] c.z.b.m.c.CustomUserMapper.getUserRoles  : ==> Parameters: 1(String)
2018-01-13 13:11:43.674 DEBUG 6152 --- [p-nio-80-exec-8] c.z.b.m.c.CustomUserMapper.getUserRoles  : <==      Total: 1
shiro角色:superadmin
2018-01-13 13:11:43.676 DEBUG 6152 --- [p-nio-80-exec-8] c.z.b.m.c.C.getPremission                : ==>  Preparing: SELECT m.id,m.menuname,m.type,m.url,m.createdate,m.updatedate FROM t_menu m LEFT JOIN t_rolemenu rm ON rm.menuid=m.id WHERE m.type='left-menu'AND rm.roidid=? 
2018-01-13 13:11:43.677 DEBUG 6152 --- [p-nio-80-exec-8] c.z.b.m.c.C.getPremission                : ==> Parameters: 0(String)
2018-01-13 13:11:43.748 DEBUG 6152 --- [p-nio-80-exec-8] c.z.b.m.c.C.getPremission                : <==      Total: 30
shiro菜單權限:/blog/system-data
shiro菜單權限:/blog/member-record-share
shiro菜單權限:/blog/system-category
shiro菜單權限:/blog/system-shielding
shiro菜單權限:/blog/feedback-list
shiro菜單權限:/blog/charts-4
shiro菜單權限:/blog/base-resource
shiro菜單權限:/blog/article-list
shiro菜單權限:/blog/picture-list
shiro菜單權限:/blog/product-list
shiro菜單權限:/blog/charts-6
shiro菜單權限:/blog/charts-7
shiro菜單權限:/blog/admin-list
shiro菜單權限:/blog/charts-2
shiro菜單權限:/blog/system-log
shiro菜單權限:/blog/admin-permission
shiro菜單權限:/blog/member-scoreoperation
shiro菜單權限:/blog/product-category
shiro菜單權限:/blog/member-level
shiro菜單權限:/blog/member-list
shiro菜單權限:/blog/product-brand
shiro菜單權限:/blog/member-record-browse
shiro菜單權限:/blog/commons-list
shiro菜單權限:/blog/save-set
shiro菜單權限:/blog/member-record-download
shiro菜單權限:/blog/charts-5
shiro菜單權限:/blog/admin-role
shiro菜單權限:/blog/charts-3
shiro菜單權限:/blog/charts-1
shiro菜單權限:/blog/member-del
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
2018-01-13 13:11:43.923 DEBUG 6152 --- [p-nio-80-exec-7] c.z.b.m.c.CustomUserMapper.getAllNodes   : ==>  Preparing: SELECT id,pid,url,menuname FROM t_menu WHERE TYPE=? and id!='0' order by orderstring desc 
2018-01-13 13:11:43.924 DEBUG 6152 --- [p-nio-80-exec-7] c.z.b.m.c.CustomUserMapper.getAllNodes   : ==> Parameters: left-menu(String)
2018-01-13 13:11:43.938 DEBUG 6152 --- [p-nio-80-exec-7] c.z.b.m.c.CustomUserMapper.getAllNodes   : <==      Total: 40
本次《/blog/leftmenu》請求的處理時間爲:22ms
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
本次《/blog/base-resource》請求的處理時間爲:1ms
本次《/blog/404》請求的處理時間爲:0ms
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
MySessionDao.doUpdate();585054a5-e499-4d46-b277-90ac9934934f
本次《/blog/getUserName》請求的處理時間爲:4ms
MySessionDao.doReadSession();C3C91739C36945524CDE58597FB55863
2018-01-13 13:11:46.232 ERROR 6152 --- [p-nio-80-exec-9] o.a.c.c.C.[.[.[.[dispatcherServlet]      : Servlet.service() for servlet [dispatcherServlet] in context with path [/blog] threw exception [Filtered request failed.] with root cause

java.lang.NullPointerException: null

shiro建立和更新sessionId無問題  。讀取的sessionId就和建立更新的id不一致,急........在線等...........

相關文章
相關標籤/搜索