Ehcache Core
  1. Ehcache Core
  2. EHC-1116

Remove call to EhCache ClassLoaderUtil.getStandardClassLoader() as it has been removed in Ehcache 2.8.3+

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: 2 Major 2 Major
    • Resolution: Fixed
    • Affects Version/s: 2.10.0
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      - Java 8
      - ehcache-jgroupsreplication 1.7
    • Terracotta Target:
      Unknown

      Description

      I'm trying to use the "file" property of net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory to be able to re-use the same JGroups configuration for EhCache and my own JGroups channels.

      <?xml version="1.0" encoding="UTF-8"?>
      <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      		 xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
      		 name="outmatch-cache" updateCheck="false">
      	<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory"
      			properties="channelName=some-name::file=jgroups-configuration.xml"
      			propertySeparator="::"/>
         <!-- ... -->
      </ehcache>
      

      Unfortunately this throws a "NoSuchMethodError", because the factory tries to load the given file via ClassLoaderUtil.getStandardClassLoader(), which has been removed from EhCache long time ago.

      java.lang.NoSuchMethodError: net.sf.ehcache.util.ClassLoaderUtil.getStandardClassLoader()Ljava/lang/ClassLoader;
      	at net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory.createCachePeerProvider(JGroupsCacheManagerPeerProviderFactory.java:61)
      	at net.sf.ehcache.config.ConfigurationHelper.createCachePeerProviders(ConfigurationHelper.java:136)
      	at net.sf.ehcache.CacheManager.configure(CacheManager.java:795)
      	at net.sf.ehcache.CacheManager.doInit(CacheManager.java:471)
      	at net.sf.ehcache.CacheManager.init(CacheManager.java:395)
      	at net.sf.ehcache.CacheManager.<init>(CacheManager.java:270)
      	at net.sf.ehcache.CacheManager.newInstance(CacheManager.java:1116)
      	at net.sf.ehcache.CacheManager.newInstance(CacheManager.java:1060)
      	...
      

      Similar to the fix done for Hibernate (https://hibernate.atlassian.net/browse/HHH-9497), this method call must be inlined and replaced with a call to Thread.currentThread().getContextClassLoader().

        Activity

        Hide
        Ramses Gomez added a comment -

        Any update on this? We have the same problem and we had to downgrade ehcache to 2.8.2 to be able to use the jgroups distribution. Thanks

        Show
        Ramses Gomez added a comment - Any update on this? We have the same problem and we had to downgrade ehcache to 2.8.2 to be able to use the jgroups distribution. Thanks
        Hide
        Rene Zanner added a comment -

        Maybe it helps when you vote for this issue - EhCache with JGroups replication does not seem to have much attention at the moment

        Show
        Rene Zanner added a comment - Maybe it helps when you vote for this issue - EhCache with JGroups replication does not seem to have much attention at the moment
        Hide
        Ryan Martin added a comment -

        We're having the same problem when trying to upgrade from Ehcache 2.6.10 to 2.10.1. Are there any workarounds?

        Show
        Ryan Martin added a comment - We're having the same problem when trying to upgrade from Ehcache 2.6.10 to 2.10.1. Are there any workarounds?
        Hide
        Rene Zanner added a comment -

        Two "workarounds" (when you want to call it that way):
        1.) Do not use "file", but only inline configuration.
        2.) Write your own "JGroupsCacheManagerPeerProviderFactory" which supports "file" correctly.
        I did the second...

        Show
        Rene Zanner added a comment - Two "workarounds" (when you want to call it that way): 1.) Do not use "file", but only inline configuration. 2.) Write your own "JGroupsCacheManagerPeerProviderFactory" which supports "file" correctly. I did the second...
        Hide
        Ryan Martin added a comment -

        Rene, based on your suggestion I constructed the attached workaround. It looks like a real patch would need to be generated against net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory. The obsolete call to ClassLoaderUtil.getStandardClassLoader() still exists in the latest release of ehcache-jgroups3replication, which is 1.7.4.

        Show
        Ryan Martin added a comment - Rene, based on your suggestion I constructed the attached workaround. It looks like a real patch would need to be generated against net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory. The obsolete call to ClassLoaderUtil.getStandardClassLoader() still exists in the latest release of ehcache-jgroups3replication, which is 1.7.4.
        Hide
        Ryan Martin added a comment -

        Here's a patch against your Ehcache SVN trunk/HEAD (r10208).

        Show
        Ryan Martin added a comment - Here's a patch against your Ehcache SVN trunk/HEAD (r10208).
        Hide
        Rishabh Monga added a comment -

        fix committed to revision 10245 of trunk

        Show
        Rishabh Monga added a comment - fix committed to revision 10245 of trunk
        Hide
        Rishabh Monga added a comment -

        Fix committed to trunk

        Show
        Rishabh Monga added a comment - Fix committed to trunk

          People

          • Assignee:
            Rishabh Monga
            Reporter:
            Rene Zanner
          • Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: