4 Replies Latest reply on Mar 16, 2006 3:32 PM by udo.krass

    HttpSessionListener

    udo.krass

      Hi,

      i have implemented the HttpSessionListener in my LoginAction class, because i want to do some database action when the session expires.
      I've read the documentation and the SourceCode of the @LoggedIn annotation. In my mind the annotation can't help when an user close his browser.
      So i write the SessionId in the database and want to delete the User when the session expires.
      But when i implement the interface-method

      public void sessionDestroyed(HttpSessionEvent se)
      with
      User logoutUser = (User)t_em.createQuery("from User where sessionId=:sessionId")
       .setParameter("sessionId", sessionId)
       .getSingleResult();
      

      i get following NullPointerException
      at org.apache.catalina.session.StandardSession.expire(StandardSession.java:685)
       at org.apache.catalina.session.StandardSession.isValid(StandardSession.java:577)
       at org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:678)
       at org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.java:663)
       at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1283)
       at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1568)
       at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1577)
       at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1577)
       at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1557)
       at java.lang.Thread.run(Thread.java:595)

      I think that this is a problem with the EntityManager. I think he isn't initialized. How i can solve that problem?
      Any ideas?

      Thanx!