gorm


spring-boot property exception while externalizing datasource properties and using actuator


Im creating a small application using spring-boot + gorm + sqlserver datasource (very similar to Tim Yates' https://github.com/timyates/data-gorm-mysql/).
My datasource properties are in application.properties:
dbDriverClassName=...
dbUsername=...
My build.gradle has
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.grails:gorm-hibernate4-spring-boot:1.0.0.RC1")
It works fine. But when I add the actuator to build.gradle, I get errors:
compile("org.springframework.boot:spring-boot-starter-actuator")
UPDATE (full stacktrace)
thread "main" org.springfra
mework.beans.factory.BeanCreationException: Error creating bean with name 'environmentEndpoint': Could not bind properties; nested exception is org.springframework.beans.NotWritablePropertyException:
Invalid property 'dbUsername' of bean class [org.springframework.boot.actuate.endpoint.EnvironmentEndpoint]: Bean property 'dbUsername' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:321)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:278)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
2014-04-05 08:40:09.661 INFO 8136 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report enabled debug logging (start with --debug)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context..AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:619)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:880)
at org.springframework.boot.SpringApplication$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at gov.texas.iph.IphApplication.main(IphApplication.groovy:25)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'dbUsername' of bean class [org.springframework.boot.actuate.endpoint.EnvironmentEndpoint]: Bean property 'dbUsername' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1064)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:922)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:82)
at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:728)
at org.springframework.validation.DataBinder.doBind(DataBinder.java:624)
at org.springframework.boot.bind.RelaxedDataBinder.doBind(RelaxedDataBinder.java:84)
at org.springframework.validation.DataBinder.bind(DataBinder.java:609)
at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfiguratory.java:275)
at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:225)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:318)
... 21 more
:bootRun FAILED
What am I missing?
Thanks!
Solution:
I changed the build.gradle line from RC1 to RC2 and there is no error now (tested switching back to RC1 to confirm error, and back to RC2 - no error).
compile("org.grails:gorm-hibernate4-spring-boot:1.0.0.RC2")
#Dave, thanks for the tip. But why do you say there is no reason to use custom DataSource, is there a better way?
I should have looked at repo.spring.io for latest version, but the stacktrace made me think it was an issue with actuator environment.

Related Links

“grails.mongodb.default.mapping” equivalent in application.yml in Grails 3.2
TenantId is null when saving an entity in a Discriminator based multi tenant application in Grails 3.2 with GORM 6
Grails 3 (unsaved) instance issue while fetching from database (GORM)
Can't use get() in domain using Grails3
GORM findAll + cannot pass dynamic List as named parameter
How to display database records in grails
Configure Grails 3.0.9 for Oracle 12c with identity PK?
Adding condition to findAll and findAllBy methods
Neo4j and Mongodb as datasource in Grails
GORM (varchar .save(), non DATE): ORA-01861: literal does not match format string
GORM addTo methods not found in Spock test
spring-boot property exception while externalizing datasource properties and using actuator
Mapping hasMany relation and saving the related data
Method on class [] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails Correctly
What happens when two app servers in cluster start LiquiBase update (via Grails)?
use of mappedBy in Many to Many relationship in Grails

Categories

HOME
cloud
gerrit
proxy
mfc
raspberry-pi
vmware
objectgears
jira
analysis
enterprise-library-5
fancybox
networkx
php-7.1
windows-phone-7
jsdoc
autoconf
facebook-instant-articles
web-sql
qhull
nhapi
tooltipster
msys2
socialengine
react-chartjs
twilio-api
.net-4.0
pim
caret
mpmediaquery
ios5
hot-module-replacement
lumberjack
tasker
import-from-excel
btrace
galleria
react-scripts
hittest
django-scheduler
objective-c-swift-bridge
url-pattern
qpid
qcustomplot
itextpdf
endeca-workbench
eclipse-clp
wordml
quicklisp
vstest.console.exe
key-management
jsapi
facebook-graph-api-v2.4
block-device
knuth
phalanger
nsbutton
document-classification
zend-route
p4java
cloud-connect
mcts
runtime.exec
spring-io
google-cloud-save
random-seed
type-equivalence
enterprisedb
tinn-r
angularjs-controller
browser-detection
yetanotherforum
coda-slider
gamequery
mirah
substrings
data-driven
project-hosting
mediarss
dbisam
data-acquisition
rtml

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App