views:

560

answers:

1

I have an external java library I am using in my Grails project. It needs a DataSource via the Spring configuration. However, the dataSource appears to not be accessible from resources.groovy. How do I get access to it? I'm using the following in resources.groovy:

beans = {
 eventDao(com.JavaClassRequiringDataSource) {
  //dataSource = ref(dataSource, true)
  dataSource = dataSource
 }
}

Running the app results in a exception:

org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingPropertyException: No such property: dataSource for class: grails.spring.BeanBuilder

Any ideas?

+2  A: 

According to http://www.grails.org/Spring+Bean+Builder your method should be right.. I just did some Googleing and found that this should do it (untested):

beans = {
 eventDao(com.JavaClassRequiringDataSource) {
  dataSource = ref('dataSource', true)
 }
}

so you do not reference it by variable, but by name. (Source: http://bit.ly/cArUL0)

sbglasius
That did it! The docs show examples like so:anotherBean(AnotherBean) { example = ref("${beanName}Bean"}Which with the ${} makes you think they are just de-aliasing the variable name.
Mike