I am working with GGTS and using Hibernate as a dB and I'm upgrading from Grails 2.3.3 to 2.5.1 - I get this error when running run-app on the project. I have read a number of posts regarding similar transactionManager problems but none seem to match my situation closely enough. Here is the initial part of the error message related to transactionManagerPostProcessor:
context.GrailsContextLoaderListener Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean '$primaryTransactionManager' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '$primaryTransactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean '$primaryTransactionManager' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '$primaryTransactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory]
Since all signs are this problem relates to setting up the databases here is the DataSource.groovy:
`
System.out.println("datasource.groovy: Hello World....?")
dataSource {
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = "S2xxxxxxxx"
}
dataSource_publish {
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = "M1xxxxxxxxxxxx"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
//cache.region.factory_class = 'grails.plugin.cache.ehcache.hibernate.BeanEhcacheRegionFactory' // For Hibernate before 4.0 and higher
//cache.region.factory_class = 'grails.plugin.cache.ehcache.hibernate.BeanEhcacheRegionFactory' // For Hibernate before 4.0 and higher
//cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' //old vers of hibernate
cache.region.factory_class = 'org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory' // Hibernate 4
}
// environment specific settings
environments {
development {
// The main HomeVu dB
dataSource {
logSql = false
pooled = true
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
}
// The SHR shared dB
dataSource_publish {
//logSql = false
//pooled = true
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
//url = "jdbc:h2:pubDb;MVCC=TRUE;LOCK_TIMEOUT=10000;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE"
//url = "jdbc:h2:pb1Db;MVCC=TRUE;LOCK_TIMEOUT10000; AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE"
url = "jdbc:h2:pub009Db;MVCC=TRUE;LOCK_TIMEOUT=10000"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
} `
I have used the recommended versions of the plugins as set out in the release notes - here is my BuildConfig.groovy:
System.out.println("BuildConfig.groovy: Hello World....?")
grails.servlet.version = "2.5" // Change depending on target container compliance (2.5 or 3.0)
grails.project.work.dir = 'target'
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.server.port.http=9000
grails.project.dependency.resolver = "maven" // MAK 12-05-16 put in to link in spring-security-core plugin
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log 'debug' // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
grailsCentral()
mavenLocal()
mavenCentral()
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
mavenRepo "http://mvnrepository.com/artifact/"
mavenRepo "http://repo.spring.io/milestone/"
grailsRepo "http://grails.org/plugin"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
}
plugins {
// Requested in grail version 2.5.1 ...
build(":release:3.1.1",
":rest-client-builder:2.1.1") {
export = false
}
compile ":hibernate:3.6.10.19"
runtime ":jquery:1.11.0.2"
build ":tomcat:7.0.55.3"
runtime ":database-migration:1.4.0"
compile ':cache:1.1.8'
compile ':asset-pipeline:2.1.5'
compile ":scaffolding:2.1.2"
}
}
Perhaps jumping Grails versions in this way rather then incrementally upgrading means that I've left some legacy settings that needs to be modified? I would welcome any suggestions?
-mike