ICEfaces
  1. ICEfaces
  2. ICE-1722

Seam redirection cause NullPointerException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6DR#5
    • Fix Version/s: 1.6.1
    • Component/s: Tool Integrations
    • Labels:
      None
    • Environment:
      Windows Vista
      JDK 1.5.0_11
      JBoss 1.2.0.GA
      IceFaces 1.6.0 DR-5
      Seam 1.2.1GA
    • Workaround Exists:
      Yes
    • Workaround Description:
      Hide
      Modifiy the following code fragment in the redirect method of the com.icesoft.faces.webapp.http.servlet.ServletExternalContext class:

          public void redirect(String requestURI) throws IOException {
              URI uri = URI.create(SeamUtilities.encodeSeamConversationId(requestURI, viewIdentifier));
              String query = uri.getQuery();

              // ###############################
              // patch/workaround modifications follow.
              // Add the following code fragment.

              if (redirector == null) {
                switchToNormalMode();
              }

             // patch/workaround code fragment end
             // ###############################


              if (query == null) {
                  redirector.redirect(uri + "?rvn=" + viewIdentifier);
              } else if (query.matches(".*rvn=.*")) {
                  redirector.redirect(uri.toString());
              } else {
                  redirector.redirect(uri + "&rvn=" + viewIdentifier);
              }
              FacesContext.getCurrentInstance().responseComplete();
          }


      Show
      Modifiy the following code fragment in the redirect method of the com.icesoft.faces.webapp.http.servlet.ServletExternalContext class:     public void redirect(String requestURI) throws IOException {         URI uri = URI.create(SeamUtilities.encodeSeamConversationId(requestURI, viewIdentifier));         String query = uri.getQuery();         // ###############################         // patch/workaround modifications follow.         // Add the following code fragment.         if (redirector == null) {           switchToNormalMode();         }        // patch/workaround code fragment end        // ###############################         if (query == null) {             redirector.redirect(uri + "?rvn=" + viewIdentifier);         } else if (query.matches(".*rvn=.*")) {             redirector.redirect(uri.toString());         } else {             redirector.redirect(uri + "&rvn=" + viewIdentifier);         }         FacesContext.getCurrentInstance().responseComplete();     }

      Description

      Seam redirections before RENDER_RESPONSE phase cause NullPointerExceptions in com.icesoft.faces.webapp.http.servlet.ServletExternalContext.

      16:50:20,188 ERROR [SeamPhaseListener] swallowing exception
       java.lang.NullPointerException
        at com.icesoft.faces.webapp.http.servlet.ServletExternalContext.redirect(ServletExternalContext.java:349)
        at org.jboss.seam.core.Manager.redirect(Manager.java:1079)
        at org.jboss.seam.core.Manager.redirect(Manager.java:1035)
        at org.jboss.seam.core.Pages.enterPage(Pages.java:257)
        at org.jboss.seam.jsf.AbstractSeamPhaseListener.enterPage(AbstractSeamPhaseListener.java:276)
        at org.jboss.seam.jsf.AbstractSeamPhaseListener.beforeRender(AbstractSeamPhaseListener.java:214)
        at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:56)
        at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
        at com.icesoft.faces.webapp.http.core.PageServer$1.respond(PageServer.java:26)
        at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:125)
        at com.icesoft.faces.webapp.http.core.PageServer.service(PageServer.java:31)
        at com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:16)
        at com.icesoft.faces.webapp.http.servlet.MultiViewServlet.service(MultiViewServlet.java:56)
        at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
        at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
        at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:89)
        at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:35)
        at com.icesoft.faces.webapp.http.servlet.PathDispatcher$Matcher.serviceOnMatch(PathDispatcher.java:52)
        at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:29)
        at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:65)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:595)

      Such redirections occurs by using Seam declarative security features, like https (scheme="https") or login page (login-required="true") in pages.xml.

      If a guest user requests a page which needs a login or a ssl protected page without ssl, seam tries to redirect
      to the login page or the same page using https protocol. To do this, Seam uses the external context redirect method.
      In the case of IceFaces ServletExternalContext the NullPointerException occurs, because in ServletExternalContext a redirector object is not initialized yet.

        Activity

        Hide
        Ted Goddard added a comment -

        Should the redirector be initialized earlier, or is the check for null sufficient?

        Show
        Ted Goddard added a comment - Should the redirector be initialized earlier, or is the check for null sufficient?
        Hide
        Greg Dick added a comment -

        I've checked in a call to switchToNormalMode during the constructor, so the redirector field is initialized.

        Show
        Greg Dick added a comment - I've checked in a call to switchToNormalMode during the constructor, so the redirector field is initialized.

          People

          • Assignee:
            Unassigned
            Reporter:
            Sven Offermann
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: