Closed qianzhiheilv closed 8 years ago
I don't see any thing Kryo related here.
I used ehcache to cache the MethodAccess and Instance to improve efficiency,It is not Kryo,It is ehcache.
Oh right, this repo is Reflectasm, not Kryo, sorry. The stacktrace shows ObjectOutputStream
is being used, which is Java's native serialization, and it can't write EntityMethodAccess
. I don't think we'll make MethodAccess Serializable
. You can wrap it in your own class that is Serializable
though.
Actually,My class Entity is already Serializable,My Entity is extend JSONObject and JSONObject extends JSON implements Map<String, Object>, JSONAware, Cloneable, Serializable, InvocationHandler. If I use ehcache to cache Entity or Class of Entity directly ,It is successful.
I changed the source code to implement Serializable,It cache successfully
EntityMethodAccess is created by ReflectASM,I think it should implements Seriablizable
java.io.NotSerializableException: com.juno.java.frame.core.model.EntityMethodAccess 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.defaultWriteFields(ObjectOutputStream.java:1547) at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:440) at net.sf.ehcache.Element.writeObject(Element.java:867) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 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:399) at net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:381) at net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:473) at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1067) at net.sf.ehcache.store.disk.DiskStorageFactory$IndexWriteTask.call(DiskStorageFactory.java:1104) at net.sf.ehcache.store.disk.DiskStorageFactory.unbind(DiskStorageFactory.java:917) at net.sf.ehcache.store.disk.DiskStore.dispose(DiskStore.java:664) at net.sf.ehcache.store.CacheStore.dispose(CacheStore.java:327) at net.sf.ehcache.Cache.dispose(Cache.java:2521) at net.sf.ehcache.CacheManager.shutdown(CacheManager.java:1523) at org.springframework.cache.ehcache.EhCacheManagerFactoryBean.destroy(EhCacheManagerFactoryBean.java:190) at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:262) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:972) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:979) at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1006) at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:982) at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:901)