title: Grails - Can't call service from Controller --> always get "Cannot invoke method on null object error"
body: <p>i have a grails application and i'm following the tutorial here:<br>
  <a href="http://www.grails.org/Services" rel="nofollow">http://www.grails.org/Services</a>  </p>
  
  <p>i have some code like  </p>
  
  <pre><code>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)
      }    
  }
  </code></pre>
  
  <p>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:</p>
  
  <blockquote>
    <p>ERROR errors.GrailsExceptionResolver  - Cannot invoke method sendHistoricalContract() on null object</p>
  </blockquote>
  
  <p>What am i doing wrong?</p>
  
  <p>Thanks in advance</p>