javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-1827

NullPointerException in RestoreViewPhase.notifyAfter

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Duplicate
    • Affects Version/s: 2.0.3
    • Fix Version/s: unscheduled
    • Component/s: lifecycle
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      1,827

      Description

      We have a big problem with Mojarra 2.0.3 - a NullPointerException during
      application startup. We have upgraded all web apps to Mojarra 2.0.3 and have
      faced this exception. Afterthat we have compared the changes and seen the
      following difference: You added a new method notifyAfter() to the Phase.java.
      notifyAfter() is called from com.sun.faces.lifecycle.RestoreViewPhase.doPhase(),
      gets UIViewRoot from FacesContext and calls AfterPhaseListener for this
      ViewRoot. Sadly, but you didn't check if ViewRoot is null. In our case it's
      null. ViewRoot can not be created with our security stuff. Our scenario:

      1) User calls the web app and is not authentificated.
      2) A security filter doesn't make a redirect to the login page self, but passes
      the current request through FacesServlet to a special JSF phase listener.
      3) The JSF phase listener makes a redirect to the login page in the
      beforePhase() method.
      4) The ViewRoot creation step is skipped because response has beed completed.
      See this block in Phase.java

      try {
      handleBeforePhase(context, listeners, event);
      if (!shouldSkip(context))

      { execute(context); // ViewRoot creation is inside of execute method }

      }

      Steps 2) and 3) are necessary by reason of Ajax redirects (JSF 2 facility). We
      let execute redirects by JSF and not by security filter in order to consider
      Ajax requests.

      Here is a small log with the NPE

      java.lang.NullPointerException
      at com.sun.faces.lifecycle.RestoreViewPhase.notifyAfter(RestoreViewPhase.java:288)
      at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)

      This is a Mojarra 2.0.3 bug. Many people have a similar problem. See e.g.
      http://forums.java.net/jive/thread.jspa?messageID=479275
      http://ocpsoft.com/support/topic/exception-handling-jsf2
      http://antwerkz.com/javabot/javabot/home/3/%23%23jsf/2/26/1/04/0/2010/

      Thanks in advance for the bugfixing!

        Activity

        Hide
        rogerk added a comment -

        See: https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1764

            • This issue has been marked as a duplicate of 1764 ***
        Show
        rogerk added a comment - See: https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1764 This issue has been marked as a duplicate of 1764 ***
        Hide
        Manfred Riem added a comment -

        Closing issue out

        Show
        Manfred Riem added a comment - Closing issue out

          People

          • Assignee:
            sheetalv
            Reporter:
            ova2
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: