Datasource defined in resources.groovy is null is Grails services

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Datasource defined in resources.groovy is null is Grails services

Shweta Nivargi

I am trying to upgrade my grails application from version 2.0 to 2.5.4
Facing issue that the jdbcTemplate bean defined in resources.groovy is null in Grails services. The same thing worked fine in earlier version of grails (tried versions 1.3.3 and 2.0).
Are there any changes in Grails version 2.5 related to autowiring of beans ?


import org.springframework.jdbc.core.JdbcTemplate
jdbcTemplate(JdbcTemplate) {
   dataSource = ref('dataSource')

dataSource {
    configClass = GrailsAnnotationConfiguration.class
    pooled = true
    autoreconnect= true 

hibernate {
    cache.region.factory_class = 'org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory' 


environments {
   development {
      dataSource {
         driverClassName = "com.mysql.jdbc.Driver"
         username = "test"
         password = "test"
         dbCreate = "update" // one of 'create', 'create-drop','update'
         pooled = true
         jmxExport = true
         url = "jdbc:mysql://host:port/dbName?autoReconnect=true"

Service class

def jdbcTemplate

def someMethod(){
Exception: Cannot invoke method queryForList() on null object. Stacktrace follows: Message: Cannot invoke method queryForList() on null object

Any help is appreciated.

Question posted on stackoverflow -


You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit
For more options, visit