1 Reply Latest reply on Sep 9, 2008 11:29 AM by nimo22

    Inject Application-Scope Component in SessionListener

    nimo22

      I have tried to inject a Seam managed Component (Application-Scope) in a HttpSessionListener. It is not working!


      I get the failure:


      Session event listener threw exception
      java.lang.NullPointerException
           at com.MyListener.sessionCreated(MyListener.java:43)
           at org.apache.catalina.session.StandardSession.tellNew(StandardSession.java:397)
           at org.apache.catalina.session.StandardSession.setId(StandardSession.java:369)
           at org.apache.catalina.session.ManagerBase.createSession(ManagerBase.java:828)
           at org.apache.catalina.session.StandardManager.createSession(StandardManager.java:291)
           at 


      org.apache.catalina.connector.Request.doGetSession(Request.java:2310)
           at org.apache.catalina.connector.Request.getSession(Request.java:2075)
           at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)


      public class myListener implements HttpSessionListener {


      So I assoume, that the injected Instance is not available when the Listener begins..


      Any Ideas?

        • 1. Re: Inject Application-Scope Component in SessionListener
          nimo22

          The problem is solved.


          At first, at had inject it in my listener via:



          @In
          MyListener myListener




          This does not work!


          I have changed it to


          MyListener myListener = new MyListener();




          Now it works!


          It s strange, as I had thought, that Seam injects a new Instance automatically, when I annotate it with @In. However, this is not the case!