i have a grails application and i’m following the tutorial here:
http://www.grails.org/Services
i have some code like
import org.springframework.beans.factory.InitializingBean
class SubmitRequestService implements InitializingBean{
def GrailsApplication1
def setting
void afterPropertiesSet(){
this.setting = GrailsApplication1.config.setting
}
def void sendHistoricalContract(HistoricalContract hc_instance){
//... blah blah whatever code
}
}
class SubmitRequestController {
def submitRequestService
static allowedMethods = [save: "POST", update: "POST", delete: "POST"]
def index = {
// .... blah blah whatever code
submitRequestService.sendHistoricalContract(historicalContractInstance)
}
}
No whatever i do, i can’t seem to get the service to be injected into the controller. Whenever I get to the line where i call the service i get the error:
ERROR errors.GrailsExceptionResolver – Cannot invoke method sendHistoricalContract() on null object
What am i doing wrong?
Thanks in advance
Burt’s answer is helpful (+1 to Burt) but in case others are following the tutorial here:
http://www.grails.org/Services
and experiencing the same issue i had, i want to make it explicit:
See Burt’s comment above on additional resources to Services and the Spring Framework.