首页 > 代码库 > 对象逆序列化报错:java.lang.ClassNotFoundException
对象逆序列化报错:java.lang.ClassNotFoundException
简单的想从保存的对象中又一次解析出对象。用了逆序列化,但是报错:
java.lang.ClassNotFoundException: xxxxxxxxxxxx
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:622)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1593)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1514)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
at xxxxxxxxxxxxxxxxx(TestMetadata.java:103)
提示类找不到。但实际上类文件是确确实实存在的。那就上网搜,果然找到答案。
能够參考文章: http://www.javapractices.com/topic/TopicAction.do?Id=45
最主要的两点:
1) 须要相同的包名
2) 相同的序列化ID
对象逆序列化报错:java.lang.ClassNotFoundException