VO类已经序列化(部分代码如下):
import java.io.Serializable;
public class Products implements Serializable{
/**
*
*/
private static final long serialVersionUID = -6193310436318894856L;
ehcache.xml文件配置如下:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../config/ehcache.xsd">
<diskStore path="java.io.tmpdir"/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
maxElementsOnDisk="10000000"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>
报错:
2013-11-13 13:53:12,901 - net.sf.ehcache.store.disk.DiskStorageFactory -78860 [org%002emapper%002e%0050roducts.data] ERROR net.sf.ehcache.store.disk.DiskStorageFactory - Disk Write of 1744313901:5183834706:org.mapper.Products.selectAllByOneBusid:0:2147483647:SELECT *
FROM PRODUCTS
WHERE BUSINESSID=?
ORDER BY PROLIKE DESC:5 failed:
java.io.NotSerializableException: org.apache.ibatis.cache.CacheKey
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:416)
at net.sf.ehcache.Element.writeObject(Element.java:835)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97)
at net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:405)
at net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:384)
at net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:485)
at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1088)
at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1072)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
请问除了vo类要序列化,还有什么需要序列化?
==================update==========================
报错点在这里:
不明白的是居然该对象不是Serializable对象,但是我明明已经实现了Serializable接口,但是却实例化失败了,这究竟是怎么回事,弄了很久没想明白?恳请各位帮忙。。
你Products 是不是引用了其它没实现序列化接口的对象了!
回复<aclass='referer'target='_blank'>@李三石:我试试回复<aclass='referer'target='_blank'>@wang_liran:检查一下你项目lib下面是不是有两个版本的mybatis包,升级mybaitis试试!貌似和这个一样https://groups.google.com/forum/#!topic/mybatis-user/kgSd2viMbok回复<aclass='referer'target='_blank'>@李三石:mybatis3.0.2回复<aclass='referer'target='_blank'>@wang_liran:mybatis那个版本?单纯的VO类,全是属性和settergetter方法,没有引用其他类没人知道吗貌似你缓存的时候使用LoggingEhcache 会有问题,换EhcacheCache就可以了!
<divclass="ref">
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。