MyFaces Core
  1. MyFaces Core
  2. MYFACES-3587

Not existing viewId will not be handled

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.8
    • Fix Version/s: 2.1.13
    • Component/s: General
    • Labels:
      None
    • Environment:
      Jetty/Tomcat, JUEL, CODI, ExtVal

      Description

      If i call a page, which does not exist, following exceptions occurs: Cannot reset buffer after response has been committed.

      After digging deeper into this problem, i found out that getViewHandlerSupport()#calculateViewId returns null and the JspViewDeclarationLanguageStrategy will be used ->

      Cannot reset buffer after response has been committed.

      occurs.

      I added a null check for the logicalViewId in RestoreViewExecutor#execute to call HttpServletResponse#sendError.

      It does not work as expected because it just renders the errorPage and no redirect will be done.

      Why there is not such null check?

      Is it possible to add this check and redirect to the web.xml defined 404 or common error page? Or should it use the ErrorHandler?

        Issue Links

          Activity

          Hide
          Leonardo Uribe added a comment -

          There is no null check by backward behavior. Add it cause problems with some compatibility tests. So, we cannot change the code in MyFaces, but it is valid to add the check in your project and there should not be any side effect. I'll close this issue as won't fix.

          Show
          Leonardo Uribe added a comment - There is no null check by backward behavior. Add it cause problems with some compatibility tests. So, we cannot change the code in MyFaces, but it is valid to add the check in your project and there should not be any side effect. I'll close this issue as won't fix.
          Hide
          Gerhard Petracek added a comment -

          we have to fix this issue.

          if the view-id is null (for whatever reason), it isn't ok to just use the JspViewDeclarationLanguageStrategy which can lead to strange errors like java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config - just because this class is needed for this strategy.

          usually modern jsf-applications don't even have a single jsp-page. backward-compatibility can't be a blocker for it, since "no view-id" doesn't mean that there is a jsp for it.

          Show
          Gerhard Petracek added a comment - we have to fix this issue. if the view-id is null (for whatever reason), it isn't ok to just use the JspViewDeclarationLanguageStrategy which can lead to strange errors like java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config - just because this class is needed for this strategy. usually modern jsf-applications don't even have a single jsp-page. backward-compatibility can't be a blocker for it, since "no view-id" doesn't mean that there is a jsp for it.
          Hide
          Martin Kočí added a comment -

          I have this issue too, but the configuration of myfaces has Facelts-VDL only (org.apache.myfaces.SUPPORT_JSP_AND_FACES_EL=false)

          In the method : ViewHandlerImpl.createView(FacesContext, String)

          getViewHandlerSupport(context).calculateViewId(context, viewId) returns null. Then getViewDeclarationLanguage(context,calculatedViewId).createView(context,calculatedViewId) throws unreadable NPE instead of java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config:

          java.lang.NullPointerException
          at org.apache.myfaces.application.ViewHandlerImpl.createView(ViewHandlerImpl.java:259)
          at javax.faces.application.ViewHandlerWrapper.createView(ViewHandlerWrapper.java:101)
          ...
          at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:235)
          at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:196)
          at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:143)
          at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.execute(CodiLifecycleWrapper.java:95)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)

          Show
          Martin Kočí added a comment - I have this issue too, but the configuration of myfaces has Facelts-VDL only (org.apache.myfaces.SUPPORT_JSP_AND_FACES_EL=false) In the method : ViewHandlerImpl.createView(FacesContext, String) getViewHandlerSupport(context).calculateViewId(context, viewId) returns null. Then getViewDeclarationLanguage(context,calculatedViewId).createView(context,calculatedViewId) throws unreadable NPE instead of java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config: java.lang.NullPointerException at org.apache.myfaces.application.ViewHandlerImpl.createView(ViewHandlerImpl.java:259) at javax.faces.application.ViewHandlerWrapper.createView(ViewHandlerWrapper.java:101) ... at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:235) at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:196) at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:143) at org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.execute(CodiLifecycleWrapper.java:95) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
          Hide
          Leonardo Uribe added a comment -

          Added web config param org.apache.myfaces.STRICT_JSF_2_VIEW_NOT_FOUND and fixed case when org.apache.myfaces.SUPPORT_JSP_AND_FACES_EL=false (catch filenotfoundexception and throw 404 response, and if vdl is not found throw 404 response too)

          Show
          Leonardo Uribe added a comment - Added web config param org.apache.myfaces.STRICT_JSF_2_VIEW_NOT_FOUND and fixed case when org.apache.myfaces.SUPPORT_JSP_AND_FACES_EL=false (catch filenotfoundexception and throw 404 response, and if vdl is not found throw 404 response too)

            People

            • Assignee:
              Leonardo Uribe
              Reporter:
              Thomas Andraschko
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development