Search code examples
grailsehcache

exception when initialising cache causes "grails run-app" to fail


In my Grails 2.5.4 app I have the following plugins installed

compile ":cache:1.1.8"
runtime ":cache-ehcache:1.0.5"

When I run grails run-app, I get the following error at startup

java.lang.NullPointerException
    at grails.plugin.cache.ehcache.GrailsEhCacheManagerFactoryBean$ReloadableCacheManager.rebuild(GrailsEhCacheManagerFactoryBean.java:171)
    at grails.plugin.cache.ehcache.EhcacheConfigLoader.reload(EhcacheConfigLoader.groovy:63)
    at grails.plugin.cache.ConfigLoader.reload(ConfigLoader.groovy:42)
    at CacheGrailsPlugin.reloadCaches(CacheGrailsPlugin.groovy:202)
    at CacheGrailsPlugin$_closure3.doCall(CacheGrailsPlugin.groovy:158)

If I build the WAR and look in the lib directory, it contains both of the following dependencies:

  • ehcache-2.9.0.jar
  • ehcache-core-2.4.8.jar

Based on the advice in this issue, I excluded the transitive ehcache-core dependency in BuildConfig

runtime (":hibernate:3.6.10.18") { 
  excludes "ehcache-core" 
}

If I rebuild the WAR, the ehcache-core JAR is excluded, but I still get the same error at startup when I run grails run-app. I suspect the cause of the issue is the ehcache dependencies, but I can't figure out which JAR I should be using.


Solution

  • Upgrading to hibernate 3.6.10.19 seemed to resolve this issue. When I build the WAR the following ehcache dependencies are included:

    • ehcache-2.9.0.jar
    • hibernate-ehcache-3.6.10.Final.jar