1 Reply Latest reply on Sep 10, 2013 11:33 PM by Alfred Wong

    ContextualHttpServletRequest throw NPE

    Alfred Wong Newbie

      I'm doing migration from seam JBoss 4.2.2 + seam v2.2.0.GA to JBoss 7 + seam v2.3.0.Final, in my previous code i can access the seam context with following way without issue:

       

      @Override

          protected void service(final HttpServletRequest arg0, final HttpServletResponse arg1) throws ServletException, IOException {

              new ContextualHttpServletRequest(arg0) {           

                  @Override

                  public void process() throws Exception {

                      doWork(arg0, arg1);               

                  }

              }.run();

          }

       

      However after migration to seam v2.3.0, i got NPE, found that the NPE happened in "ServletContexts.instance()" showed in following code:

       

      org.jboss.seam.servlet.ContextualHttpServletRequest

      public void run() throws ServletException, IOException

         {     

            log.debug("beginning request");

                

            // Force creation of the session

            if (request.getSession(false) == null)

            {

               request.getSession(true);

            }

           

            // Begin request and Seam life cycle only if it is not nested

            // ContextualHttpServletRequest

            if (getCounterValue() == 0)

            {        

               ServletLifecycle.beginRequest(request);

               ServletContexts.instance().setRequest(request);        

               restoreConversationId();

               Manager.instance().restoreConversation();

               ServletLifecycle.resumeConversation(request);

               handleConversationPropagation();

            }

            ...

         }

       

      org.jboss.seam.web.ServletContexts

      public static ServletContexts instance()

         {

            if ( !Contexts.isEventContextActive() )

            {

               throw new IllegalStateException("no event context active");

            }

            return (ServletContexts) Component.getInstance(ServletContexts.class, ScopeType.EVENT);

         }

       

      In the log, i saw trace message "Seam component not found: org.jboss.seam.web.servletContexts".

       

      Anybody know why? My project is a WAR resided in an EAR.