DiskStorageFactory 报错!!!!求指教

xlati 发布于 2014/07/09 17:23
阅读 4K+
收藏 0

@JFinal 你好,想跟你请教个问题: 测式环境不会报错,但正式环境一直报这个错误???求指教


2014-07-09 17:19:33 [net.sf.ehcache.store.disk.DiskStorageFactory] Disk Write of 88481de6-b078-4962-b925-1f7f1e8b3c3c failed:  -(:503)
 java.io.NotSerializableException: com.jfinal.log.Log4jLogger
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1183)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at java.util.HashMap.writeObject(HashMap.java:1133)
at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at org.apache.shiro.session.mgt.SimpleSession.writeObject(SimpleSession.java:461)
at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:440)
at net.sf.ehcache.Element.writeObject(Element.java:797)
at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97)
at net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:413)
at net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:392)
at net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:493)
at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1154)
at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1138)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
2014-07-09 17:19:33 [net.sf.ehcache.store.disk.DiskStorageFactory] Disk Write of 88481de6-b078-4962-b925-1f7f1e8b3c3c failed:  -(:503)

加载中
1
糊搞
你需要缓存的数据没有实现序列化接口
1
JFinal
JFinal

引用来自“JFinal”的评论

被缓存对象的类需要实现  Serializable 接口

引用来自“吴红佳”的评论

请问下波总,我的User是继承自Model的,显然已经实现了Serializable 接口,我现在把List<User>放入缓存时就会报这样的错误,知道怎么能解决吗?

错误提示很明显是 Log4jLogger 对象无法被缓存,可能是间接缓存了它,例如, Model 中有个 private Logger log = Logger.getLogger(..) 属性。解决办法是在这类属性上使用transient 关键字:

transient private Logger log ....

0
JFinal
JFinal
被缓存对象的类需要实现  Serializable 接口
0
gzfdxy
gzfdxy
mybatis-ehcache的高版本的问题,换成 mybatis-ehcache-1.0.1.jar就可以解决问题了!
0
吴红佳
吴红佳

引用来自“JFinal”的评论

被缓存对象的类需要实现  Serializable 接口
请问下波总,我的User是继承自Model的,显然已经实现了Serializable 接口,我现在把List<User>放入缓存时就会报这样的错误,知道怎么能解决吗?
0
吴红佳
吴红佳

引用来自“JFinal”的评论

被缓存对象的类需要实现  Serializable 接口

引用来自“吴红佳”的评论

请问下波总,我的User是继承自Model的,显然已经实现了Serializable 接口,我现在把List<User>放入缓存时就会报这样的错误,知道怎么能解决吗?

引用来自“JFinal”的评论

错误提示很明显是 Log4jLogger 对象无法被缓存,可能是间接缓存了它,例如, Model 中有个 private Logger log = Logger.getLogger(..) 属性。解决办法是在这类属性上使用transient 关键字:

transient private Logger log ....

感谢波总,找了好久没找到这个属性,原来在基类中。这个transient 属性学习了

Logger导入的是JFinal中的,换成Log4j的就没问题了。

返回顶部
顶部