title: EHCache RMI Replication on JBoss/EC2 throws java.rmi.NoSuchObjectException: no such object in table
body: <p>Trying to create an EHCache RMI-based cache replication between 2 JBoss 4.2 servers on Amazon EC2. Currently, this is set up as manual peer discovery with one-way replication from Server2 to Server1. </p>
  
  <p>Configuration as under:</p>
  
  <p>Server 1</p>
  
  <pre><code>&lt;cacheManagerPeerProviderFactory
     class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
     properties="peerDiscovery=manual"/&gt;
  
  &lt;cacheManagerPeerListenerFactory
     class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
     properties="hostName=host1, port=40001,  
                       socketTimeoutMillis=3000"/&gt;
  
  &lt;cache name="cache1"
          maxElementsInMemory="0"
          eternal="false"
          overflowToDisk="true"
          timeToIdleSeconds="600"
          timeToLiveSeconds="600"
          diskPersistent="true"
          diskExpiryThreadIntervalSeconds="60"
          statistics="true"&gt;
          &lt;cacheEventListenerFactory
                            class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
                            properties="replicatePuts=false, replicateUpdates=false, 
                  replicateRemovals=false"/&gt;
  &lt;/cache&gt;
  </code></pre>
  
  <p>Server 2</p>
  
  <pre><code>&lt;cacheManagerPeerProviderFactory
     class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
     properties="peerDiscovery=manual,
               rmiUrls=//host1:40001/cache1"/&gt;
  
  &lt;cacheManagerPeerListenerFactory
     class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
     properties="hostName=host2, port=40002,  
                       socketTimeoutMillis=3000"/&gt;
  
  &lt;cache name="cache1"
          maxElementsInMemory="0"
          eternal="false"
          overflowToDisk="false"
          timeToIdleSeconds="7200"
          timeToLiveSeconds="7200"&gt;
          &lt;cacheEventListenerFactory
                            class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
                            properties="replicateAsynchronously=false"/&gt;
      &lt;/cache&gt;
  </code></pre>
  
  <p>However, when I put new elements into the cache on Server2, it throws the following exception:</p>
  
  <pre><code>Jul 10, 2012 3:25:37 PM net.sf.ehcache.distribution.RMISynchronousCacheReplicator replicatePutNotification
  SEVERE: Exception on replication of putNotification. no such object in table. Continuing...
  java.rmi.NoSuchObjectException: no such object in table
            at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
            at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
            at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
            at net.sf.ehcache.distribution.RMICachePeer_Stub.put(Unknown Source)
            at net.sf.ehcache.distribution.RMISynchronousCacheReplicator.replicatePutNotification(RMISynchronousCacheReplicator.java:149)
            at net.sf.ehcache.distribution.RMISynchronousCacheReplicator.notifyElementPut(RMISynchronousCacheReplicator.java:132)
            at net.sf.ehcache.event.RegisteredEventListeners.notifyListener(RegisteredEventListeners.java:294)
            at net.sf.ehcache.event.RegisteredEventListeners.invokeListener(RegisteredEventListeners.java:284)
            at net.sf.ehcache.event.RegisteredEventListeners.internalNotifyElementPut(RegisteredEventListeners.java:144)
            at net.sf.ehcache.event.RegisteredEventListeners.notifyElementPut(RegisteredEventListeners.java:122)
            at net.sf.ehcache.Cache.notifyPutInternalListeners(Cache.java:1515)
            at net.sf.ehcache.Cache.putInternal(Cache.java:1490)
            at net.sf.ehcache.Cache.put(Cache.java:1417)
            at net.sf.ehcache.Cache.put(Cache.java:1382)
  </code></pre>
  
  <p>I've also tried this with Server2 as a stand-alone Java program (using the same ehcache.xml as shown above) instead of a JBoss server. But as long as Server1 is a JBoss server, I see this exception.</p>
  
  <p>It works great if I deploy Server1 and Server2 (JBoss or Java program) on the same host. But as soon as I move them to different hosts, it dies on me.</p>
  
  <p>Any help will be greatly appreciated. Thanks ...</p>