在从一个VM向另一个VM进行轮询RMI调用时,我遇到了一些零星的异常。两个VM之间的类路径看起来是一致的。我正在使用64位Java- jres是一致的(jdk/v1.6.0_23-64bit)。
-XX:+UseCompressedOops flag & -XX:+UseConcMarkSweepGC
存在不一致性,但我不知道这些是否可能是根本原因?
调用(客户端)VM设置了-XX:+UseCompressedOops & -XX:+UseConcMarkSweepGC
,在其中进行getStatistics()调用的服务器VM没有进行此类设置。
需要注意以下几点:
在遇到异常后,随后在同一VM之间进行的调用在数天内都是正常的——即无效的ClassException是暂时的问题。
[class]和[fieldname]每次遇到异常时都会有所不同,其中异常是java.io.InvalidClassException: [class]; incompatible types for field [fieldname]
使用带有-XX:+UseCompressedOops
的64位 VM进行RMI调用(序列化)到一个未设置压缩oops的另一个64位VM中是否存在问题?
堆栈信息:
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
感谢你的帮助