title: Facing Null Pointer Exception: Cannot invoke method firstMethod() on null Object : Grails 3.2.10
body: <p>I wrote a simple rest-api Controller in Grails 3.2.10 version. Below are my system configurations. Created application is also rest-api profile.</p>
  
  <p>Grails Version: 3.2.10
  Groovy Version: 2.4.10
  JVM Version: 1.8.0_131</p>
  
  <p>Sample code written is as follows:
  Controller:</p>
  
  <pre><code>package mydevpath
  
  import grails.rest.*
  import grails.converters.*
  
  class LoginController {
  static responseFormats = ['json', 'xml']
  
  def index() {
          def loginService
          def val = loginService.firstMethod()
  
          render 'hello World' + val
       }
     }
  </code></pre>
  
  <p>Service :`
       package mydevpath</p>
  
  <pre><code>import grails.transaction.Transactional
  
   @Transactional
   class LoginService {
      static scope = "prototype"
  
       def firstMethod(){
          return 'From Service'
    }
  }
  </code></pre>
  
  <p>On running and hitting the URL , I am facing below error.</p>
  
  <pre><code>NullPointerException occurred when processing request
  : [POST] /login
  Cannot invoke method firstMethod() on null object. Stacktrace follows:
  
  java.lang.reflect.InvocationTargetException: null
          at org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker.
  invoke(DefaultGrailsControllerClass.java:211)
          at org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrai
  lsControllerClass.java:188)
  </code></pre>
  
  <p>Can somebody help me with the Issue?</p>
  
  <p>Regards,
  Pramod</p>