title: Grails service ->java.lang.NullPointerException: Cannot invoke method serviceMethod() on null object
body: <p>I have Class in src/groovy . I want to use my service here . but error occurred "No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here ". i try to debug but not able to find . can you please help me that what is my mistake . </p>
  
  <pre><code>class ListenerSession implements HttpSessionListener  {
      def transactionService = new TransactionService ()
      public ListenerSession() {
      }
      public void sessionCreated(HttpSessionEvent sessionEvent){
      }
      public void sessionDestroyed(HttpSessionEvent sessionEvent) {
          HttpSession session = sessionEvent.getSession();
          User user=session["user"]
          if(user){
              try{
                  java.util.Date date = session['loginDate']
                  transactionService.updateUserLastLogin(user,date)
  -----}catch (Exception e) {
                  println e
      }
  </code></pre>
  
  <p>code in service is: </p>
  
  <pre><code>def updateUserLastLogin(User user,Date date){
          try{
              User.withTransaction{
                  println "121212"
                  user.lastLogin=date
                  user.loginDuration=new Date().time - user?.lastLogin?.time
                  def x=user.save()
              }
          }catch (Exception e) {
              println e
          }
      }
  </code></pre>