title: Cannot invoke method pullLogs() on null object when calling service in controller
body: <p>I have search around stack overflow and have found some similar instances of my problem but there fixes done seem to work for mine. (example of simular one:<a href="https://stackoverflow.com/questions/4559270/grails-cant-call-service-from-controller-always-get-cannot-invoke-method">Grails - Can&#39;t call service from Controller --&gt; always get &quot;Cannot invoke method on null object error&quot;</a>)</p>
  
  <p>My service can be summed up like this </p>
  
  <pre><code>class AuditService {
  
  
    AuditService auditService
  
    def sql
    def dataSource
    static transactional = true
  
  
    def pullLogs(String username, String id) { 
      if(username != null &amp;&amp; id != null) {
  
          sql = new Sql(dataSource)
          println "Data source is: " + dataSource.toString()
          def schema = dataSource.properties.defaultSchema
  
          sql.query('select USERID, AUDIT_DETAILS from DEV.AUDIT_LOG T WHERE XMLEXISTS(\'\$s/*/user[id=\"' + id + '\" or username=\"'+username+'\"]\' passing T.AUDIT_DETAILS as \"s\") ORDER BY AUDIT_EVENT', []) { ResultSet rs -&gt;
              while (rs.next()) { 
                  def auditDetails = new XmlSlurper().parseText(rs.getString('AUDIT_EVENT_DETAILS'))
                  println auditDetails
              }
          }
          sql.close()
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The way im trying to call it is likes this</p>
  
  <pre><code>UserController {
  
    def auditService
  
  
    show(Long id){
  
      def UserInstance = User.get(id)
  
      //Also tried def auditResults = auditServices.pullLogs(UserInstance.username, UserInstance.id)
      def auditResults = auditServices(UserInstance.username, UserInstance.id)
      System.out.println(" "+ auditResults)
      [UserInstance: UserInstance,params:params]
    }
  }
  </code></pre>
  
  <p>The error I get is </p>
  
  <pre><code>Class:
  java.lang.NullPointerException
  Message:
   Cannot invoke method pullLogs() on null object
  </code></pre>
  
  <p>Im pretty stumped. (Query was given to me)</p>
  
  <p>Any Ideas/Opnions/Help is greatly appriciated!</p>
  
  <p>Thanks!</p>