java.io.InvalidClassException: javax.swing.text.DefaultStyledDocument; local class incompatible: stream classdesc serialVersionUID = 940485415728614849, local class serialVersionUID = 7691029896427935656
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:579)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1601)
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)
[catch] at jxmessenger.ui.chat.ChatTopComponent.deserializeEditTPDoc(ChatTopComponent.java:361)
at jxmessenger.ui.chat.ChatTopComponent.pipeMsgEvent(ChatTopComponent.java:267)
at net.jxta.util.JxtaBiDiPipe.push(JxtaBiDiPipe.java:1141)
at net.jxta.util.JxtaBiDiPipe.processIncomingMessage(JxtaBiDiPipe.java:1122)
at net.jxta.impl.util.pipe.reliable.ReliableInputStream.queueIncomingMessage(ReliableInputStream.java:549)
at net.jxta.impl.util.pipe.reliable.ReliableInputStream.recv(ReliableInputStream.java:419)
at net.jxta.util.JxtaBiDiPipe.receiveMessage(JxtaBiDiPipe.java:1037)
at net.jxta.util.JxtaBiDiPipe.pipeMsgEvent(JxtaBiDiPipe.java:982)
at net.jxta.util.JxtaBiDiPipe$1.pipeMsgEvent(JxtaBiDiPipe.java:507)
at net.jxta.impl.pipe.InputPipeImpl.processIncomingMessage(InputPipeImpl.java:214)
at net.jxta.impl.endpoint.EndpointServiceImpl.processIncomingMessage(EndpointServiceImpl.java:1024)
at net.jxta.impl.endpoint.router.EndpointRouter.processIncomingMessage(EndpointRouter.java:1666)
at net.jxta.impl.endpoint.EndpointServiceImpl.processIncomingMessage(EndpointServiceImpl.java:1024)
at net.jxta.impl.endpoint.netty.AsynchronousNettyMessenger$2.run(AsynchronousNettyMessenger.java:132)
at net.jxta.impl.util.threads.RunnableAsCallableWrapper.call(RunnableAsCallableWrapper.java:17)
at net.jxta.impl.util.threads.RunMetricsWrapper.call(RunMetricsWrapper.java:50)
at net.jxta.impl.util.threads.QueueTimeRunMetricsWrapper.call(QueueTimeRunMetricsWrapper.java:34)
at net.jxta.impl.util.threads.RunMetricsWrapper.run(RunMetricsWrapper.java:93)
at net.jxta.impl.util.threads.QueueTimeRunMetricsWrapper.run(QueueTimeRunMetricsWrapper.java:9)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:579)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1601)
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)
[catch] at jxmessenger.ui.chat.ChatTopComponent.deserializeEditTPDoc(ChatTopComponent.java:361)
at jxmessenger.ui.chat.ChatTopComponent.pipeMsgEvent(ChatTopComponent.java:267)
at net.jxta.util.JxtaBiDiPipe.push(JxtaBiDiPipe.java:1141)
at net.jxta.util.JxtaBiDiPipe.processIncomingMessage(JxtaBiDiPipe.java:1122)
at net.jxta.impl.util.pipe.reliable.ReliableInputStream.queueIncomingMessage(ReliableInputStream.java:549)
at net.jxta.impl.util.pipe.reliable.ReliableInputStream.recv(ReliableInputStream.java:419)
at net.jxta.util.JxtaBiDiPipe.receiveMessage(JxtaBiDiPipe.java:1037)
at net.jxta.util.JxtaBiDiPipe.pipeMsgEvent(JxtaBiDiPipe.java:982)
at net.jxta.util.JxtaBiDiPipe$1.pipeMsgEvent(JxtaBiDiPipe.java:507)
at net.jxta.impl.pipe.InputPipeImpl.processIncomingMessage(InputPipeImpl.java:214)
at net.jxta.impl.endpoint.EndpointServiceImpl.processIncomingMessage(EndpointServiceImpl.java:1024)
at net.jxta.impl.endpoint.router.EndpointRouter.processIncomingMessage(EndpointRouter.java:1666)
at net.jxta.impl.endpoint.EndpointServiceImpl.processIncomingMessage(EndpointServiceImpl.java:1024)
at net.jxta.impl.endpoint.netty.AsynchronousNettyMessenger$2.run(AsynchronousNettyMessenger.java:132)
at net.jxta.impl.util.threads.RunnableAsCallableWrapper.call(RunnableAsCallableWrapper.java:17)
at net.jxta.impl.util.threads.RunMetricsWrapper.call(RunMetricsWrapper.java:50)
at net.jxta.impl.util.threads.QueueTimeRunMetricsWrapper.call(QueueTimeRunMetricsWrapper.java:34)
at net.jxta.impl.util.threads.RunMetricsWrapper.run(RunMetricsWrapper.java:93)
at net.jxta.impl.util.threads.QueueTimeRunMetricsWrapper.run(QueueTimeRunMetricsWrapper.java:9)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
原因是Swing的版本不匹配,一台机器是JDK1.7.0-b147(Swing版本为1.7),另一台机器是1.6.0_25-b06(Swing版本为1.6)
JavaDoc中有对AbstractDocument,DefaultStyledDocument和PlainDocument,有以下说明:
|
但是使用XMLEncoder/XMLDecoder后仍然有问题(或者用的不对),这里不详细表述;
看来只能通过某种方式保证Swing版本一致(例如使用自带jre或者针对不同版本发布不同的程序包)。
-----------------------------------------------------------------------------------------------------
下面是用来查看Swing版本的代码,来自于网络,具体出处懒得找了,这里不列出了:
import javax.swing.*;
public class Version{
public static void main(String args[]){
JLabel l=new JLabel();
Package p=Package.getPackage("javax.swing");
if(p!=null){
System.out.print("Swing Version: ");
System.out.println(p.getSpecificationVersion());
}
p=Package.getPackage("java.awt");
if(p!=null){
System.out.print("AWT Version: ");
System.out.println(p.getSpecificationVersion());
}
}
}
public class Version{
public static void main(String args[]){
JLabel l=new JLabel();
Package p=Package.getPackage("javax.swing");
if(p!=null){
System.out.print("Swing Version: ");
System.out.println(p.getSpecificationVersion());
}
p=Package.getPackage("java.awt");
if(p!=null){
System.out.print("AWT Version: ");
System.out.println(p.getSpecificationVersion());
}
}
}