shiro 集成缓存中遇到 java.io.NotSerializableException: org.apache.shiro.util.SimpleByteSource
2015-03-02 00:22
711 查看
java.io.NotSerializableException: org.apache.shiro.util.SimpleByteSource
是由于 SimpleByteSource 没有实现序列化接口导致。
在集成redis缓存, 开启缓存认证时候报错
<!-- 启用认证缓存,当用户登录一次后将不在查询数据库来获取用户信息,直接在从缓存获取 -->
<property name="authenticationCachingEnabled" value="true" />
我的解决方案 写一个新类去继承SimpleByteSource,并实现序列化接口
public class MySimpleByteSource extends SimpleByteSource implements Serializable {
public MySimpleByteSource(byte[] bytes) {
super(bytes);
// TODO Auto-generated constructor stub
}
}
在处理认证中
protected AuthenticationInfo doGetAuthenticationInfo(
AuthenticationToken token) throws AuthenticationException {
return new SimpleAuthenticationInfo(model, user.getPassword(), new MySimpleByteSource(salt), getName());
}
是由于 SimpleByteSource 没有实现序列化接口导致。
在集成redis缓存, 开启缓存认证时候报错
<!-- 启用认证缓存,当用户登录一次后将不在查询数据库来获取用户信息,直接在从缓存获取 -->
<property name="authenticationCachingEnabled" value="true" />
我的解决方案 写一个新类去继承SimpleByteSource,并实现序列化接口
public class MySimpleByteSource extends SimpleByteSource implements Serializable {
public MySimpleByteSource(byte[] bytes) {
super(bytes);
// TODO Auto-generated constructor stub
}
}
在处理认证中
protected AuthenticationInfo doGetAuthenticationInfo(
AuthenticationToken token) throws AuthenticationException {
return new SimpleAuthenticationInfo(model, user.getPassword(), new MySimpleByteSource(salt), getName());
}
相关文章推荐
- shiro 使用缓存时出现:java.io.NotSerializableException: org.apache.shiro.util.SimpleByteSource
- shiro 使用缓存时出现:java.io.NotSerializableException: org.apache.shiro.util.SimpleByteSource
- java.io.NotSerializableException: org.hibernate.util.MarkerObject解决办法
- java.io.NotSerializableException: org.apache.log4j.Logger
- spark1.4 读取hbase 0.96 报错 java.io.NotSerializableException: org.apache.hadoop.hbase.io.ImmutableBytes
- Caused by: java.io.NotSerializableException: org.apache.spark.SparkContext
- java.lang.ClassNotFoundException: org.apache.http.util.Args
- java.lang.ClassNotFoundException: org.apache.http.util.Args
- java.io.NotSerializableException: java.util.ArrayList$SubList
- Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils
- org.apache.tomcat.util.bcel.classfile.ClassFormatException: null is not a Java .class file
- Caused by: java.lang.ClassNotFoundException: org.apache.shiro.spring.LifecycleBeanPostProcessor
- org.apache.tomcat.util.bcel.classfile.ClassFormatException: null is not a Java .class file
- JDBC 连接 hive2 遇到的java.lang.ClassNotFoundException: org.apache.hive.jdbc.HiveDriver
- java.lang.ClassNotFoundException: org.apache.http.util.Args
- MAVEN Error: java.lang.ClassNotFoundException: org.apache.commons.io.output.DeferredFileOutputStream
- Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils
- java.lang.ClassNotFoundException: org.apache.http.util.Args
- 友盟分享遇到Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.entity.mime.Mu
- org.apache.tomcat.util.bcel.classfile.ClassFormatException: It is not a Java .class file