Reputation: 2603
I recently moved part of the config from application.yml
to application.groovy
so we can use environment variables in the config. And once we did that we are getting an ugly exception. The worst part is that we are getting the same exception even if we revert everything.
I cleaned up the project, even checked out a fresh copy of the code.... nothing helps.
At this point, I have no idea where to go from here.
The exception is:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Unsatisfied dependency expressed through method 'methodValidationPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastoreServiceRegistry': Cannot resolve reference to bean 'hibernateDatastore' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is groovy.lang.MissingPropertyException: No such property: generator for class: org.grails.orm.hibernate.cfg.HibernateMappingBuilder
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1177)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1071)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:225)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:703)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at grails.boot.GrailsApp.run(GrailsApp.groovy:84)
at grails.boot.GrailsApp.run(GrailsApp.groovy:393)
at grails.boot.GrailsApp.run(GrailsApp.groovy:380)
at grails.boot.GrailsApp$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136)
at priz.Application.main(Application.groovy:13)
...
Here is my application.yml
---
grails:
profile: rest-api
codegen:
defaultPackage: priz
gorm:
reactor:
# Whether to translate GORM events into Reactor events
# Disabled by default for performance reasons
events: false
info:
app:
name: '@info.app.name@'
version: '@info.app.version@'
grailsVersion: '@info.app.grailsVersion@'
spring:
main:
banner-mode: "off"
groovy:
template:
check-template-location: false
# Spring Actuator Endpoints are Disabled by Default
endpoints:
enabled: false
jmx:
enabled: true
---
grails:
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
types:
json:
- application/json
- text/json
hal:
- application/hal+json
- application/hal+xml
xml:
- text/xml
- application/xml
atom: application/atom+xml
css: text/css
csv: text/csv
js: text/javascript
rss: application/rss+xml
text: text/plain
all: '*/*'
urlmapping:
cache:
maxsize: 1000
controllers:
defaultScope: singleton
converters:
encoding: UTF-8
---
grails:
cors:
enabled: true
allowedOrigins:
- http://localhost:4200
---
hibernate:
cache:
queries: false
use_second_level_cache: false
use_query_cache: false
and application.groovy
grails {
plugin {
springsecurity {
filterChain {
chainMap = [
[
pattern = '/v1/login',
filters = 'anonymousAuthenticationFilter'
],
[
pattern = '/v1/api/**',
filters = 'JOINED_FILTERS,-anonymousAuthenticationFilter,-exceptionTranslationFilter,-authenticationProcessingFilter,-securityContextPersistenceFilter,-rememberMeAuthenticationFilter'
]
]
}
userLookup {
userLookup = 'User'
authorityJoinClassName = 'UserRole'
}
authority {
className = 'Role'
}
rest {
token {
storage {
jwt {
secret = "secret"
}
}
validation {
enableAnonymousAccess = true
}
}
}
}
}
}
grails.plugin.springsecurity.roleHierarchy = '''
ROLE_ADMIN > ROLE_USER
'''
grails.plugin.databasemigration.updateOnStartFileName = 'changelog.groovy'
grails.gorm.failOnError = true
grails.gorm.default.mapping = {
id generator = 'identity'
}
dataSource {
pooled = true
jmxExport = true
driverClassName = "org.h2.Driver"
// dialect = "hibernate.MyPostgreSQLDialect"
username = "sa"
password = ''
properties {
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 600000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState;StatementCache(max=200)"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}
environments {
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
}
}
development {
dataSource {
dbCreate = ""
driverClassName = "org.postgresql.Driver"
url = "jdbc:postgresql://localhost:5432/priz"
username = "postgres"
password = "postgres"
logSql = false
}
}
production {
dataSource {
dbCreate = ""
pooled = true
url = System.getenv('PRIZ_DATABASE_URL')
driverClassName = "org.postgresql.Driver"
username = System.getenv('PRIZ_DATABASE_USER')
password = System.getenv('PRIZ_DATABASE_PASSWORD')
logSql = false
properties {
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 600000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState;StatementCache(max=200)"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}
}
}
priz {
auth0 {
domain = "https://priz-dev.auth0.com"
cache {
size = 5
expiresIn = 10
}
rateLimit {
bucketSize = 10
refillRate = 1
}
api {
domain = "priz-dev.auth0.com"
clientId = "secret"
clientSecret = "secret"
}
}
}
Upvotes: 1
Views: 1369
Reputation: 84756
I guess it should be:
grails.gorm.default.mapping = {
id column: 'id', generator: 'identity'
}
Upvotes: 2