我在定义和不定义serialVersionUID的情况下执行了操作。 我已使用 ehcache 作为我的缓存,并且我正在尝试复制缓存。 **以下是我的日志**
Severe: [Replication Thread] WARN net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator - Unable to send message to remote peer. Message was: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.io.InvalidClassException: org.hibernate.type.AbstractStandardBasicType; local class incompatible: stream classdesc serialVersionUID = -7392726925440390214, local class serialVersionUID = 7995037332590373518 Severe: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.io.InvalidClassException: org.hibernate.type.AbstractStandardBasicType; local class incompatible: stream classdesc serialVersionUID = -7392726925440390214, local class serialVersionUID = 7995037332590373518
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:389)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:283)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:260)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:161)
at net.sf.ehcache.distribution.RMICachePeer_Stub.send(Unknown Source)
at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.writeReplicationQueue(RMIAsynchronousCacheReplicator.java:314)
at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.replicationThreadMain(RMIAsynchronousCacheReplicator.java:127)
at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.access$000(RMIAsynchronousCacheReplicator.java:58)
at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator$ReplicationThread.run(RMIAsynchronousCacheReplicator.java:389)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.io.InvalidClassException: org.hibernate.type.AbstractStandardBasicType; local class incompatible: stream classdesc serialVersionUID = -7392726925440390214, local class serialVersionUID = 7995037332590373518
实体类 用户.java
public class User implements Serializable {
private static final long serialVersionUID = -7392726925440390214L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private long id;
@Column(name = "USER_NAME")
private String userName;
@Column(name = "USER_ADDRESS")
private String userAddress;
最佳答案
您尝试通过 RMI 发送 Hibernate 类型信息,每一端都有不同版本的 Hibernate。
解决方案:使用相同版本。
关于java - 无法将消息发送到远程对等本地类不兼容 : stream classdesc serialVersionUID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49255064/