Grails Spring Security ACL kann Cache Bean nicht initiieren

Problem: Grails 2.5.0 kann aufgrund der folgenden Ausgabe nicht gestartet werden.

| Error 2015-06-29 14:34:16,474 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener - Error initializing the application: Error creating bean with name 'grails.plugin.springsecurity.ui.RegisterController': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'instanceControllerTagLibraryApi': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.codehaus.groovy.grails.plugins.web.api.ControllerTagLibraryApi.setTagLibraryLookup(org.codehaus.groovy.grails.web.pages.TagLibraryLookup); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gspTagLibraryLookup': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grails.plugin.springsecurity.SecurityTagLib': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webExpressionHandler': Cannot resolve reference to bean 'permissionEvaluator' while setting bean property 'permissionEvaluator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'permissionEvaluator': Cannot resolve reference to bean 'aclService' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityAclAclService': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aclCache': Cannot resolve reference to bean 'ehcacheAclCache' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ehcacheAclCache': Cannot resolve reference to bean 'aclCacheManager' while setting bean property 'cacheManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aclCacheManager': Invocation of init method failed; nested exception is net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.
The source of the existing CacheManager is: DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]
view raw grails.log hosted with ❤ by GitHub

Hintergund: Hibernate verwendet einen Cache und hat diesen bereits gestartet. Das ACL Plugin verwendet ebenfalls einen Cache unter dem gleichen Namen.

Lösung

Schritt 1: Ergänzen der Abhängigkeiten, um des Cache Plugin.

grails.servlet.version = "3.0"
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
grails.project.fork = [
test: false,
run: false,
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]
def gebVersion = "0.10.0"
def ghostDriverVersion = "1.2.0"
def webdriverVersion = "2.45.0"
grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
inherits("global") {
}
log "error"
checksums true
legacyResolve false
repositories {
inherits true
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenCentral()
}
dependencies {
test "org.gebish:geb-junit3:${gebVersion}"
test "org.gebish:geb-junit4:${gebVersion}"
test "org.gebish:geb-spock:${gebVersion}"
test "org.seleniumhq.selenium:selenium-support:${webdriverVersion}"
test "org.seleniumhq.selenium:selenium-chrome-driver:${webdriverVersion}"
test "org.seleniumhq.selenium:selenium-firefox-driver:${webdriverVersion}"
test "org.seleniumhq.selenium:selenium-ie-driver:${webdriverVersion}"
test("com.codeborne:phantomjsdriver:1.2.1") {
transitive = false
}
test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
}
plugins {
build ":tomcat:7.0.55"
compile ":scaffolding:2.1.2"
compile ':cache:1.1.8'
compile ":asset-pipeline:1.9.9"
compile ":cache:1.1.8"
compile ":spring-security-core:2.0-RC5"
compile ":spring-security-ui:1.0-RC2"
compile ":spring-security-acl:2.0-RC2"
runtime ":hibernate4:4.3.6.1"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
runtime ':twitter-bootstrap:3.3.2.1'
test ":remote-control:1.5"
test ":geb:${gebVersion}"
}
}

Schritt 2: Konfiguration des Cache, zur gemeinsamen Nutzung.

import org.springframework.cache.ehcache.EhCacheManagerFactoryBean
beans = {
aclCacheManager(EhCacheManagerFactoryBean) {
shared = true
}
}

Kommentare