• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Not a Bug
  • ehcache-core,ehcache-jgroupsreplication
  • cdennis
  • Reporter: andrey_a
  • February 13, 2012
  • 0
  • Watchers: 2
  • July 27, 2012
  • February 14, 2012

Description

I’m trying to configure EhCache with JGroups-based replication, but I get log flooded with the following exception as soon as first element is added to the cache:

12061 [Replication Thread] ERROR net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator - Exception on flushing of replication queue: null. Continuing… java.lang.NullPointerException at net.sf.ehcache.distribution.RMISynchronousCacheReplicator.listRemoteCachePeers(RMISynchronousCacheReplicator.java:335) at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.flushReplicationQueue(RMIAsynchronousCacheReplicator.java:299) at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.replicationThreadMain(RMIAsynchronousCacheReplicator.java:119) at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator.access$100(RMIAsynchronousCacheReplicator.java:57) at net.sf.ehcache.distribution.RMIAsynchronousCacheReplicator$ReplicationThread.run(RMIAsynchronousCacheReplicator.java:371)

Some details are also available here: http://stackoverflow.com/questions/9228526/ehcache-jgroups-give-exception-on-flushing-of-replication-queue-null

Comments

Fiona OShea 2012-02-13

Is there something we need to fix here?

Chris Dennis 2012-02-13

From looking at your ehcache configuration on the stack-overflow post it looks like you are mixing RMI configuration with JGroups configuration.

The first section in your configuration configures JGroups based peer discovery:

  <cacheManagerPeerProviderFactory
    class="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory"
    properties="jgroups.xml"
  />

However, in the cache section you’ve configured RMI based replication.

    <cacheEventListenerFactory
      class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
      properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true, replicateUpdatesViaCopy=true, replicateRemovals=true"
    />

There is a guide to JGroups based replication here: http://www.ehcache.org/documentation/replication/jgroups-replicated-caching. For example if you switch to a section such as this for your caches then you should have more luck:

  <cacheEventListenerFactory
    class="net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory"
    properties="replicateAsynchronously=true, replicatePuts=true,
      replicateUpdates=true, replicateUpdatesViaCopy=false,
      replicateRemovals=true" />

The NullPointerExceptions you are seeing are not very user friendly however. I’ll look in to seeing if we can fail-fast with such broken configurations.

Andrey Adamovich 2012-02-14

Thanks, Chris. You are right I probably blindly copied it from another configutaion file. It looks better now.