无效类异常:<类>;字段<字段名称>不兼容的类型
在从一个 VM 到另一个 VM 进行轮询 RMI 调用时,我遇到了一些零星的异常。VM 之间的类路径看起来是一致的。我使用的是64位java - jres是一致的(jdk / v1.6.0_23-64bit)。VM 之间存在不一致,但我不知道这两者是否可能是根本原因?-XX:+UseCompressedOops flag & -XX:+UseConcMarkSweepGC
调用(客户端)VM 已设置,对其进行 getStatistics() 调用的服务器 VM 未设置。-XX:+UseCompressedOops & -XX:+UseConcMarkSweepGC
注意事项:-
遇到异常后,同一 VM 之间的后续调用在几天内正常 - 即无效类异常是暂时性问题。
[class] 和 [fieldname] 每次遇到异常时都会有所不同,其中异常是 java.io.InvalidClassException: [class];字段 [字段名] 的类型不兼容
从 64 位 VM 到另一个未设置为使用压缩 oop 的 64 位 VM 进行 RMI 调用(序列化)是否存在任何问题?-XX:+UseCompressedOops
堆栈:
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.InvalidClassException: testserver.cluster.Status; incompatible types for field committed
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:173)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
at $Proxy14.getStatistics(Unknown Source)
at testserver.rm.RM$Check.run(RM.java:1593)
Caused by: java.io.InvalidClassException: testserver.cluster.Status; incompatible types for field committed
at java.io.ObjectStreamClass.matchFields(ObjectStreamClass.java:2210)
at java.io.ObjectStreamClass.getReflector(ObjectStreamClass.java:2105)
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:602)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:306)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:155)
... 4 more
感谢您的帮助