2
votes

I'm trying to use the latest version of the grails ehcache plugin (1.0.4) in my grails application, however when I add the plugin as a dependency in BuildConfig.groovy I get a compile error on startup:

| Error Compilation error: startup failed:
Compile error during compilation with javac.
/Users/rcgeorge23/Documents/workspace/grails-cache-ehcache/src/java/grails/plugin/cache/ehcache/GrailsEhCacheManagerFactoryBean.java:202: error: ReloadableCacheManager.ProxyEhcache is not abstract and does not override abstract method getSearchesPerSecond() in Ehcache
                protected class ProxyEhcache implements Ehcache {
                          ^
/Users/rcgeorge23/Documents/workspace/grails-cache-ehcache/src/java/grails/plugin/cache/ehcache/GrailsEhCacheManagerFactoryBean.java:805: error: getStatistics() in ReloadableCacheManager.ProxyEhcache cannot implement getStatistics() in Ehcache
                        public StatisticsGateway getStatistics()
                                                 ^
  return type StatisticsGateway is not compatible with Statistics
/Users/rcgeorge23/Documents/workspace/grails-cache-ehcache/src/java/grails/plugin/cache/ehcache/GrailsEhCacheManagerFactoryBean.java:663: error: cannot find symbol
                                return getUnderlyingEhcache(name).getSearchAttributes();
                                                                 ^
  symbol:   method getSearchAttributes()
  location: interface Ehcache
/Users/rcgeorge23/Documents/workspace/grails-cache-ehcache/src/java/grails/plugin/cache/ehcache/GrailsEhCacheManagerFactoryBean.java:660: error: method does not override or implement a method from a supertype
                        @Override
                        ^
/Users/rcgeorge23/Documents/workspace/grails-cache-ehcache/src/java/grails/plugin/cache/ehcache/GrailsEhCacheManagerFactoryBean.java:758: error: cannot find symbol
                                return getUnderlyingEhcache(name).calculateOnDiskSize();
                                                                 ^
  symbol:   method calculateOnDiskSize()
  location: interface Ehcache
/Users/rcgeorge23/Documents/workspace/grails-cache-ehcache/src/java/grails/plugin/cache/ehcache/GrailsEhCacheManagerFactoryBean.java:755: error: method does not override or implement a method from a supertype
                        @Override
                        ^
/Users/rcgeorge23/Documents/workspace/grails-cache-ehcache/src/java/grails/plugin/cache/ehcache/GrailsEhCacheManagerFactoryBean.java:765: error: cannot find symbol
                                return getUnderlyingEhcache(name).getAll(arg0);
                                                                 ^
  symbol:   method getAll(Collection)
  location: interface Ehcache
  where CAP#1 is a fresh type-variable:
    CAP#1 extends Object from capture of ?
/Users/rcgeorge23/Documents/workspace/grails-cache-ehcache/src/java/grails/plugin/cache/ehcache/GrailsEhCacheManagerFactoryBean.java:761: error: method does not override or implement a method from a supertype
                        @Override
                        ^
/Users/rcgeorge23/Documents/workspace/grails-cache-ehcache/src/java/grails/plugin/cache/ehcache/GrailsEhCacheManagerFactoryBean.java:770: error: cannot find symbol
                                return getUnderlyingEhcache(name).hasAbortedSizeOf();
                                                                 ^
  symbol:   method hasAbortedSizeOf()
  location: interface Ehcache
/Users/rcgeorge23/Documents/workspace/grails-cache-ehcache/src/java/grails/plugin/cache/ehcache/GrailsEhCacheManagerFactoryBean.java:768: error: method does not override or implement a method from a supertype
                        @Override
                        ^
/Users/rcgeorge23/Documents/workspace/grails-cache-ehcache/src/java/grails/plugin/cache/ehcache/GrailsEhCacheManagerFactoryBean.java:777: error: cannot find symbol
                                getUnderlyingEhcache(name).putAll(arg0);
                                                          ^
  symbol:   method putAll(Collection)
  location: interface Ehcache
/Users/rcgeorge23/Documents/workspace/grails-cache-ehcache/src/java/grails/plugin/cache/ehcache/GrailsEhCacheManagerFactoryBean.java:773: error: method does not override or implement a method from a supertype
                        @Override
                        ^
/Users/rcgeorge23/Documents/workspace/grails-cache-ehcache/src/java/grails/plugin/cache/ehcache/GrailsEhCacheManagerFactoryBean.java:783: error: method putIfAbsent in interface Ehcache cannot be applied to given types;
                                return getUnderlyingEhcache(name).putIfAbsent(arg0, arg1);
                                                                 ^
  required: Element
  found: Element,boolean

Has anyone else had this problem? I notice the ehcache plugin is still being maintained, so I guess it works with current versions of grails, however I can't seem to get it to work for me. I've also tried cloning the latest commit from the grails-ehcache project in github and referencing this as a local plugin project, but I still get the same compile error.

I'm using Grails 2.3.7.

EDIT 1:

I was able to get my app to start up using version 1.0.0 of the ehcache plugin, although I imagine I'm probably missing out on some important enhancements if I use this version...

EDIT 2:

Ok for now, I've just cloned version 1.0.0 from github and cherry picked the fix for the TTL defect (https://jira.grails.org/browse/GPCACHEEHCACHE-6). It'd be good to find out why I can't get 1.0.4 working, but I have a workaround for now.

1
Try a grails clean-all and grails clean (can't hurt). - nickdos
Haha, yep that's the first thing I tried! - rcgeorge23

1 Answers

0
votes

It works for me with a basic 2.3.11 app, so I'm guessing that something else is bringing in an older version of the ehcache jar. You'll probably see that if you run grails dependency-report.

The 1.0.4 plugin depends on net.sf.ehcache:ehcache:2.9.0 but most other plugins that depend on Ehcache haven't been updated to the most recent versions, so you'll probably see that you also have a dependency for net.sf.ehcache:ehcache-core:2.4.8, but the version might be off a bit. Notice that they dropped the "-core" from the name, which could also be contributing to this because unless the group and name are exactly the same, one jar cannot evict another. So it's possible for two people to have both jars in the classpath, but they end up in the opposite order, and it works fine for one because the newer jar's classes are loaded, but not the other because the the older classes are loaded.

You'll get a better dependency report if you switch temporarily from

grails.project.dependency.resolver = "maven"

to

grails.project.dependency.resolver = "ivy"

in BuildConfig.groovy - the maven resolver only generates output to the console, but the Ivy output also includes HTML output.

If you can't resolve this, create a small separate test app and configure it so it fails the same way - you probably just need to copy BuildConfig.groovy from your app. Create an issue at https://jira.grails.org/browse/GPCACHEEHCACHE and I'll take a look. If all you need to do is change BuildConfig.groovy, attach that to the issue, otherwise run grails bug-report and attach the zip it creates.