Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-10904

Ehcache with RMI replication bug

    XMLWordPrintable

    Details

      Description

      The fix for bug https://jira.springsource.org/browse/SPR-8081 has introduced a new one.
      It's related to ehcache and RMI replication.
      If you try to use RMICacheManagerPeerListener , spring instantiated cache manager created with EhCacheManagerFactoryBean, and spring instantiated caches created with EhCacheFactoryBean, it won't replicate caches anymore.
      This issue affected us when we tried to migrate from spring 3.1.1 to spring 3.1.2 to solve the statistics enable problem.
      After surfing on spring sources, I found that RMICacheManagerPeerListener tries to create the RMI port to communicate with other cache instances in
      two points:
      1- Ehcache manager initialization
      At this point, caches has not been created... so RMICacheManagerPeerListener won't create any rmi listener port.
      2- After a new cache has been added to cacheManager

      In EhCacheFactoryBean.afterPropertiesSet:

      EhCacheFactoryBean.java
      .....
           rawCache = createCache();
           this.cacheManager.addCache(rawCache);
           }
      
         if (this.cacheEventListeners != null) {
             for (CacheEventListener listener : this.cacheEventListeners) {
                  rawCache.getCacheEventNotificationService().registerListener(listener);
              }
          }
      
      

      The problem is that RMICacheManagerPeerListener creates RMI ports based on the existence of net.sf.ehcache.distribution.CacheReplicator event listeners for caches.
      This initialization will be executed after "this.cacheManager.addCache(rawCache)" sentences, but It won't find any CacheReplicator because the listeners
      has not been added to the notifications service yet. In the previous spring version, the event listeners were added after cache creation time and before addCache call.

        Attachments

          Activity

            People

            Assignee:
            juergen.hoeller Juergen Hoeller
            Reporter:
            fmateo Facundo Mateo
            Last updater:
            Spring Issuemaster
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              1 year, 25 weeks, 1 day ago