当逆序列化一个对象时发生 '
ClassNotFoundException '
我正在写一个ActiveMQ消息的解析程序。
消息队列中有三种类:B、C、D的消息,都是类A的子类。
ByteArrayInputStream bis = new ByteArrayInputStream(map.get("POJO"));
ObjectInputStream ois = new ObjectInputStream(bis);
Object fuzzyObj = ois.readObject();
当执行程序到
ois.readObject() 时,系统报出异常:
引用 java.lang.ClassNotFoundException : com.sfx.entity.PerformanceEntityNetWorkIF
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.io.ObjectInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at mypackage.MqVisit.DealMSG(MqVisit.java:140)
at mypackage.MqVisit.RecvMSGandProcess(MqVisit.java:81)
at Talk_MQ_SQL.main(Talk_MQ_SQL.java:28)
SO帖子http://stackoverflow.com/questions/18331987/java-serialization-classnotfoundexception-when-deserializing-an-object的方法也木有解决问题
请问这是啥子原因涅
------解决方案-------------------- 当发生错误时,试着把Stream里面的内容打印出来,看看有什么特点
------解决方案-------------------- 没有找到这个PerformanceEntityNetWorkIF实体类