0 Replies Latest reply on Oct 20, 2009 7:39 AM by Arup Sarkar

    Exception sending context destroyed event to listener instance of class org.jboss.seam.example.jpa.StartupServletContextListener

    Arup Sarkar Newbie
      Hi,

        I am starting Seam using MockServlet in servlet listener and handling LifeCycle using ContextualHttpServletRequest in a servlet filter. My application deployed on Tomcat6. While shutting down Tomcat. I am getting an exception due to null ServletContext.

      The sample codes are in below

      [Seam startup::ServletContextListener]

      MockServletContext servletContext = new MockServletContext();
      ServletLifecycle.beginApplication(servletContext);
      new Initialization(servletContext).create().init();

      [LifeCycle Startup:: Filter]

      ContextualHttpServletRequest ctx = new ContextualHttpServletRequest((HttpServletRequest) request) {
                      @Override
                      public void process() throws Exception
                      {
                          chain.doFilter(request, response);
                      }
                  };
                  ctx.run();

      [Seam shutdown :: ServletContextListener]

      ServletLifecycle.endApplication();

      [The exception while shutting down the tomcat]

      Oct 20, 2009 4:29:33 PM org.apache.catalina.core.StandardContext listenerStop
      SEVERE: Exception sending context destroyed event to listener instance of class org.jboss.seam.example.jpa.StartupServletContextListener
      java.lang.NullPointerException
              at org.jboss.seam.servlet.ServletApplicationMap.keySet(ServletApplicationMap.java:65)
              at org.jboss.seam.contexts.BasicContext.getNames(BasicContext.java:58)
              at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:241)
              at org.jboss.seam.contexts.Lifecycle.endApplication(Lifecycle.java:61)
              at org.jboss.seam.contexts.ServletLifecycle.endApplication(ServletLifecycle.java:149)
              at org.jboss.seam.contexts.ServletLifecycle.endApplication(ServletLifecycle.java:144)
              at org.jboss.seam.example.jpa.AppStartup.shutdown(AppStartup.java:92)
              at org.jboss.seam.example.jpa.StartupServletContextListener.contextDestroyed(StartupServletContextListener.java:45)
              at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3973)
              at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4577)
              at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1098)
              at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1098)
              at org.apache.catalina.core.StandardEngine.stop(StandardEngine.java:448)
              at org.apache.catalina.core.StandardService.stop(StandardService.java:584)
              at org.apache.catalina.core.StandardServer.stop(StandardServer.java:744)
              at org.apache.catalina.startup.Catalina.stop(Catalina.java:633)
              at org.apache.catalina.startup.Catalina.start(Catalina.java:608)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
              at java.lang.reflect.Method.invoke(Unknown Source)
              at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
              at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

      Regards
      Arup