alexxiyang / shiro-redis

shiro only provide the support of ehcache and concurrentHashMap. Here is an implement of redis cache can be used by shiro. Hope it will help you!
MIT License
1.17k stars 446 forks source link

ERROR org.crazycake.shiro.RedisSessionDAO - read session error. settionId=adb79750-ea4a-4326-81b7-5a696a8c861a #95

Closed liulei008 closed 4 years ago

liulei008 commented 5 years ago

ERROR org.crazycake.shiro.RedisSessionDAO - read session error. settionId=adb79750-ea4a-4326-81b7-5a696a8c861a,求作者帮忙解决下~~

alexxiyang commented 5 years ago

请问有更具体的异常信息吗?

liulei008 commented 5 years ago

12:15:30.346 logback [] [] [http-nio-8000-exec-3] ERROR org.crazycake.shiro.RedisSessionDAO - read session error. settionId=682b7e52-c319-464c-8252-ec95730fd158 12:15:30.351 logback [] [] [http-nio-8000-exec-3] ERROR c.n.e.a.a.c.GlobalExceptionHandler - There is no session with id [682b7e52-c319-464c-8252-ec95730fd158] org.apache.shiro.session.UnknownSessionException: There is no session with id [682b7e52-c319-464c-8252-ec95730fd158] 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:148) at org.apache.shiro.session.mgt.AbstractNativeSessionManager.lookupRequiredSession(AbstractNativeSessionManager.java:152) at org.apache.shiro.session.mgt.AbstractNativeSessionManager.getAttribute(AbstractNativeSessionManager.java:249) at org.apache.shiro.session.mgt.DelegatingSession.getAttribute(DelegatingSession.java:141)

liulei008 commented 5 years ago

image 提示反序列化的时候有问题

xuanj commented 5 years ago

spring boot 在分离依赖jar,配置文件时,生产也会报这个错

Rusell-Wu commented 5 years ago

spring boot 在分离依赖jar,配置文件时,生产也会报这个错

我解决了,分离打包的时候,这个错误是由于分离打包-序列化时使用的 ClassLoader不同导致找不到class,出现的现象就是在IDEA能正常运行,打包之后就会报there is not session的错误,解决的方法是在maven打包插件那里加<classifier>exec</classifier>,我是看了这个博客才知道的,https://www.cnblogs.com/chen-lhx/p/7778111.html image

或者参考https://www.jianshu.com/p/32d38a7fd20a 用JdkSerializationRedisSerializer,这个我试了,也可以

gorouter commented 4 years ago

这个问题我在序列化时也遇到了,3.2.3版本,请问怎样解决?或者哪个版本没有这个问题? public byte[] serialize(Object object) throws SerializationException { byte[] result = new byte[0]; if (object == null) { return result; } else { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(128); if (!(object instanceof Serializable)) { throw new SerializationException("requires a Serializable payload but received an object of type [" + object.getClass().getName() + "]"); } else { try { ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteStream); objectOutputStream.writeObject(object); // 这里报错了 objectOutputStream.flush(); result = byteStream.toByteArray(); return result; } catch (IOException var5) { throw new SerializationException("serialize error, object=" + object, var5); } } } }

Rusell-Wu commented 4 years ago

这个问题我在序列化时也遇到了,3.2.3版本,请问怎样解决?或者哪个版本没有这个问题? public byte[] serialize(Object object) throws SerializationException { byte[] result = new byte[0]; if (object == null) { return result; } else { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(128); if (!(object instanceof Serializable)) { throw new SerializationException("requires a Serializable payload but received an object of type [" + object.getClass().getName() + "]"); } else { try { ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteStream); objectOutputStream.writeObject(object); // 这里报错了 objectOutputStream.flush(); result = byteStream.toByteArray(); return result; } catch (IOException var5) { throw new SerializationException("serialize error, object=" + object, var5); } } } } 我是自己重写了一个序列化类和反序列化类解决的