title: ............Error | java.lang.NullPointerException: Cannot invoke method saveDataentryDetails() on null object
body: <p>I got below error when i try to save a form details. (when i click submit button from my dataentry.gsp file)
  I think the error occured at my controller where i calling the service.</p>
  
  <pre><code>Error  | java.lang.NullPointerException: Cannot invoke method saveDataentryDetails() on null object
  </code></pre>
  
  <p>here is my dataentry.gsp</p>
  
  <pre><code>&lt;%@ page contentType="text/html;charset=UTF-8" %&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/&gt;
  &lt;meta name="layout" content="main"/&gt;
  &lt;title&gt;Data Entry&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="saveMsgDiv"&gt;&lt;/div&gt;
  &lt;g:formRemote name="dataEntryForm" update="saveMsgDiv" url="[controller: 'DataEntry', action:'saveAjax']"&gt;
  
    &lt;table align="center"&gt;
              &lt;tr&gt;
              &lt;td&gt;
                  &lt;label for='employeeId'&gt;EmployeeID:&lt;/label&gt;
               &lt;/td&gt;
               &lt;td&gt;
                  &lt;g:textField name='employee_id' required id='employee_id'/&gt;
              &lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
              &lt;td&gt;
                  &lt;label for='team'&gt;Team:&lt;/label&gt;
              &lt;/td&gt;
              &lt;td&gt;
                &lt;g:select name='team' required id='team' from="${['Java', 'QA', 'Database']}"
                noSelection="['':'---select---']"/&gt;
              &lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
                &lt;td&gt;
                  &lt;label for='receiptDate'&gt;Receipt Date:&lt;/label&gt;
                &lt;/td&gt;
                &lt;td&gt;
                  &lt;g:textField name='receipt_dt' required id='receipt_dt'/&gt;
                &lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
                 &lt;td&gt;
                  &lt;label for='restaurantName'&gt;Restaurant Name:&lt;/label&gt;
                 &lt;/td&gt;
                  &lt;td&gt;
                  &lt;g:textField name='restaurant_name' required id='restaurant_name'/&gt;
                  &lt;/td&gt;
             &lt;/tr&gt;
             &lt;tr&gt;
              &lt;td&gt;
                  &lt;label for='numberOfPersons'&gt;Number of Persons:&lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                  &lt;g:textField name='number_of_persons' required id='number_of_persons' maxlength="3"/&gt;
              &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
              &lt;td&gt;
                  &lt;label for='amount'&gt;Amount:&lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                  &lt;g:textField name='amount' required id='amount'/&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
              &lt;td&gt;
                  &lt;label for='billSubmittedDate'&gt;Bill Submitted Date:&lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                  &lt;g:textField name='bill_submitted_dt' required id='bill_submitted_dt'/&gt;
              &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
              &lt;td&gt;
                  &lt;label for='reImbursed'&gt;Reimbursed:&lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                  &lt;g:textField name='reimbursed' required id='reimbursed'/&gt;
              &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
              &lt;td&gt;
                  &lt;label for='submitBank'&gt;Submitted to Bank:&lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                  &lt;g:textField name='presented_bank_fl' required id='presented_bank_fl'/&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
              &lt;td&gt;
                  &lt;label for='dateOfSubmission'&gt;Date of Bank Submission:&lt;/label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                  &lt;g:textField name='presented_bank_dt' required id='presented_bank_dt'/&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
              &lt;td colspan="2" style="text-align:center;"&gt;
              &lt;g:submitButton name="Submit" style="cursor:pointer"/&gt;
              &lt;/td&gt;
              &lt;/tr&gt;
         &lt;/table&gt;
    &lt;/g:formRemote&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>here is my DataEntryController.groovy</p>
  
  <pre><code>package com.standout.utilityapplication
  
  
  import java.util.Map;
  
  import grails.plugin.springsecurity.annotation.Secured
  import groovy.sql.Sql
  
  
  @Secured(['ROLE_DATAENTRY'])
  class DataEntryController {
  
      def dataSource
      DataEntrySevice service
      def index() { }
      def dataentry(){
          println("Inside DataEntryController")
      }
  
      def saveAjax(){
          def result
          try{
              service.saveDataentryDetails(params)
  
              }
              catch(Exception e){
                  e.printStackTrace();
              }
  
      }
  
  }
  </code></pre>
  
  <p>here is my DataEntryService.groovy</p>
  
  <pre><code>package com.standout.utilityapplication
  
  import grails.transaction.Transactional
  import groovy.sql.Sql
  import org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap
  
  @Transactional
  class DataEntrySevice {
  
      def dataSource
      def int saveDataentryDetails(Map params) {
          def result
          try{
              println("Inside saveDataentryAjax() method of dataentry")
  
  
              Dataentry d = new Dataentry();
              d.amount = params.amount
              d.bill_submitted_dt = params.bill_submitted_dt
              d.employee_id = params.employee_id
              d.number_of_persons = params.number_of_persons
              d.presented_bank_dt = params.presented_bank_dt
              d.presented_bank_fl = params.presented_bank_fl
              d.receipt_dt = params.receipt_dt
              d.reimbursed = params.reimbursed
              d.restaurant_name = params.restaurant_name
              d.team = params.team
              d.save(failOnError:true);
  
              }
              catch(Exception e){
                  e.printStackTrace();
              }
              catch(Exception e){
                  println(e)
              }
              return result
      }
  }
  </code></pre>
  
  <p>Can anyone help?</p>