RMIAsynchronousCacheReplicator - Unable to send message to remote peer

1,292 views
Skip to first unread message

Mo Yakubu

unread,
Mar 20, 2016, 6:36:03 PM3/20/16
to ehcache-users
  1. What version of Ehcache you are currently using;
  2. Paste the configuration for the Cache/CacheManager you have an issue with;
  3. Add any name and version of other library or framework you use Ehcache with (e.g. Hibernate);
  4. Providing JDK and OS versions maybe useful as well.

  1. What version of Ehcache you are currently using; 2.4.3
  2. Paste the configuration for the Cache/CacheManager you have an issue with;
  3. Add any name and version of other library or framework you use Ehcache with (e.g. Hibernate);
  4. Providing JDK and OS versions maybe useful as well. 1.8 JDK

Hi All,

I am fairly new to using EhCache & Terracotta. I am working on an application that currently uses EhCache to implement 2nd level caching in Hibernate with external cache provider as EHCache in my application.

I am trying to use cache replication on two nodes (two separate applications that share the same core) both have the following versions of libraries:

Node 1: Hibernate: 1.2.6, EhCache: 2.4.3, Spring: 4.1.6.RELEASE
Node 2: Hibernate: 4.3.8.Final, EhCache: 2.4.3, Spring: 1.2.6

The first application starts fine, however when I launch the second application on startup I get the following Exceptions, all related to the RMI replicator thread:

It appeared to me it is something to do with different versions of Hibernate in the two applications having a different LongType serial version id. However, I am not using one at least directly within the application.

I also thought of upgrading the Hibernate version in the second application, but as a result a lot of the logic related to spring also needed to be upgraded it seems.

I will really appreciate any suggestions, ideas, clue or help on this please. Thank you in anticipation for your responses.

3822 [Replication Thread] WARN net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator - Unable to send message to remote peer.  Message was: error marshalling arguments; nested exception is:
 java
.net.SocketException: Broken pipe
java
.rmi.MarshalException: error marshalling arguments; nested exception is:
 java
.net.SocketException: Broken pipe
 at sun
.rmi.server.UnicastRef.invoke(UnicastRef.java:158)
 at net
.sf.ehcache.distribution.RMICachePeer_Stub.send(Unknown Source)
 at net
.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.flushReplicationQueue(RMIAsynchronousCacheReplicator.java:317)
 at net
.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.replicationThreadMain(RMIAsynchronousCacheReplicator.java:119)
 at net
.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.access$100(RMIAsynchronousCacheReplicator.java:56)
 at net
.sf.ehcache.distribution.RMIAsynchronousCacheReplicator$ReplicationThread.run(RMIAsynchronousCacheReplicator.java:376)
Caused by: java.net.SocketException: Broken pipe
 at java
.net.SocketOutputStream.socketWrite0(Native Method)
 at java
.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
 at java
.net.SocketOutputStream.write(SocketOutputStream.java:153)
 at java
.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
 at java
.io.BufferedOutputStream.write(BufferedOutputStream.java:126)
 at java
.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1877)
 at java
.io.ObjectOutputStream$BlockDataOutputStream.writeByte(ObjectOutputStream.java:1915)
 at java
.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1576)
 at java
.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:351)
 at sun
.rmi.server.UnicastRef.marshalValue(UnicastRef.java:294)
 at sun
.rmi.server.UnicastRef.invoke(UnicastRef.java:153)
 
... 5 more
4901 [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.LongType; local class incompatible: stream classdesc serialVersionUID = -3687678703082902834, local class serialVersionUID = -4805151846854886626
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.LongType; local class incompatible: stream classdesc serialVersionUID = -3687678703082902834, local class serialVersionUID = -4805151846854886626
 at sun
.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:354)
 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$79(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:1142)
 at java
.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java
.lang.Thread.run(Thread.java:745)
 at sun
.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:276)
 at sun
.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253)
 at sun
.rmi.server.UnicastRef.invoke(UnicastRef.java:162)
 at net
.sf.ehcache.distribution.RMICachePeer_Stub.send(Unknown Source)
 at net
.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.flushReplicationQueue(RMIAsynchronousCacheReplicator.java:317)
 at net
.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.replicationThreadMain(RMIAsynchronousCacheReplicator.java:119)
 at net
.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.access$100(RMIAsynchronousCacheReplicator.java:56)
 at net
.sf.ehcache.distribution.RMIAsynchronousCacheReplicator$ReplicationThread.run(RMIAsynchronousCacheReplicator.java:376)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
 java
.io.InvalidClassException: org.hibernate.type.LongType; local class incompatible: stream classdesc serialVersionUID = -3687678703082902834, local class serialVersionUID = -4805151846854886626
 at sun
.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:311)
 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$79(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:1142)
 at java
.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java
.lang.Thread.run(Thread.java:745)


Fabien Sanglier

unread,
Mar 22, 2016, 5:38:46 PM3/22/16
to ehcach...@googlegroups.com
Hey,

As you pointed out already, the issue here is really the different versions of hibernate between the 2 applications. Overall, because you use ehcache as the hibernate 2nd level cache, what ends up in cache are some hibernate objects, AND because you want to replicate between these applications, the cached hibernate objects need to be serialized and unserialized, and as such, the hibernate versions should match for that to work well.

And as expected, The stack trace clearly shows an invalid class exception with the hibernate LongType class that is different between the 2 hibernate versions used in the 2 applications.

Overall no easy solution here apart from using the same hibernate version between the 2 applications, OR not using 2nd level cache at all and cache outside of hibernate (using business objects you control...)

Hope that helps,

Fabien
--
You received this message because you are subscribed to the Google Groups "ehcache-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-user...@googlegroups.com.
To post to this group, send email to ehcach...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-users/1c56a21d-c3c8-4a30-94ca-05b7f0805109%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Fabien Sanglier
fabiens...@gmail.com

Mo Yakubu

unread,
Mar 23, 2016, 3:26:57 AM3/23/16
to ehcache-users
Hey Fabien,

Thanks a lot for your reply. I will upgrade hibernate to make them same version.

Mo
...
Reply all
Reply to author
Forward
0 new messages