ICEfaces
  1. ICEfaces
  2. ICE-595

Error Messaging: ICEfaces + Facelets doesn't give 404 error page

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 1.5
    • Fix Version/s: 1.6
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      Operating System: All
      Platform: All

      Description

      I tried two variations of trying to access a non-existant page, first with a
      redirect JSP, and secondly with an address typed into the address bar. In both
      cases, a blank page was served, instead of a 404 resource not available.


      15:59:58,640 ERROR [D2DFaceletViewHandler] Error renderResponse.
      /autoBeans.xhtml Not Found in ExternalContext as a Resource
      java.io.FileNotFoundException: /autoBeans.xhtml Not Found in ExternalContext as
      a Resource
              at
      com.sun.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:114)
              at
      com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:86)
              at
      com.icesoft.faces.facelets.D2DFaceletViewHandler.renderResponse(D2DFaceletViewHandler.java:209)
              at
      com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:123)
              at
      com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
              at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
              at
      com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet.service(PersistentFacesServlet.java:279)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
              at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
              at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at
      org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
              at
      org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
              at
      org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
              at
      org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
              at
      org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:703)
              at
      org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:670)
              at org.apache.jsp.index_jsp._jspService(index_jsp.java:47)
              at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
              at
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
              at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
              at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
              at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
              at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
              at
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
              at
      org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
              at
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
              at
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
              at
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
              at
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
              at
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
              at
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
              at
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
              at
      org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
              at
      org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
              at
      org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
              at java.lang.Thread.run(Thread.java:595)



      16:01:08,093 ERROR [D2DFaceletViewHandler] Error renderResponse. /evil.xhtml Not
      Found in ExternalContext as a Resource
      java.io.FileNotFoundException: /evil.xhtml Not Found in ExternalContext as a
      Resource
              at
      com.sun.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:114)
              at
      com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:86)
              at
      com.icesoft.faces.facelets.D2DFaceletViewHandler.renderResponse(D2DFaceletViewHandler.java:209)
              at
      com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:123)
              at
      com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
              at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
              at
      com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet.service(PersistentFacesServlet.java:279)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
              at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
              at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
              at
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
              at
      org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
              at
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
              at
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
              at
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
              at
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
              at
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
              at
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
              at
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
              at
      org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
              at
      org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
              at
      org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
              at java.lang.Thread.run(Thread.java:595)
      16:01:08,093 INFO [STDOUT] DOMResponseWriter.writeDOM() viewNumber: 1003,
      session: org.apache.catalina.session.StandardSessionFacade@5292e6, no
      deWriter: null

        Issue Links

          Activity

          Mark Collette created issue -
          Hide
          Ken Fyten added a comment -

          Target v1.0.1.

          Ted, please re-assign as appropriate.

          Show
          Ken Fyten added a comment - Target v1.0.1. Ted, please re-assign as appropriate.
          Hide
          Ted Goddard added a comment -

          Ted to investigate and determine if a general framework bug.

          Show
          Ted Goddard added a comment - Ted to investigate and determine if a general framework bug.
          Hide
          Ken Fyten added a comment -

          Any update on this?

          Show
          Ken Fyten added a comment - Any update on this?
          Hide
          Ted Goddard added a comment -

          This bug is present with both Facelets and ICEfaces JSP processing. This error is more difficult to catch
          with ICEfaces because normal JSP processing is not used (this is on the level of a feature request rather
          than a simple bug fix).

          Show
          Ted Goddard added a comment - This bug is present with both Facelets and ICEfaces JSP processing. This error is more difficult to catch with ICEfaces because normal JSP processing is not used (this is on the level of a feature request rather than a simple bug fix).
          Hide
          Mark Collette added a comment -

          I think that stock Facelets does this, right at the point where it uses the
          ResourceResolver to find the .xhtml file to show. We'd just have to duplicate
          this behaviour.

          Show
          Mark Collette added a comment - I think that stock Facelets does this, right at the point where it uses the ResourceResolver to find the .xhtml file to show. We'd just have to duplicate this behaviour.
          Icefaces Administrator made changes -
          Field Original Value New Value
          issue.field.bugzillaimportkey 599 11864
          Ken Fyten made changes -
          Affects Version/s 1.5 [ 10027 ]
          Affects Version/s 1.0 [ 10024 ]
          Ken Fyten made changes -
          Summary ICEfaces + Facelets doesn't give 404 error page Error Messaging: ICEfaces + Facelets doesn't give 404 error page
          Ken Fyten made changes -
          Assignee Ted Goddard [ ted.goddard ] Mark Collette [ mark.collette ]
          Ken Fyten made changes -
          Assignee Priority P3
          Hide
          Ted Goddard added a comment -

          The difficult part of this bug is that you would like to use HttpServletResponse.sendError(), but the response may already by "committed" by the time ICEfaces can determine that no such page exists.

          Show
          Ted Goddard added a comment - The difficult part of this bug is that you would like to use HttpServletResponse.sendError(), but the response may already by "committed" by the time ICEfaces can determine that no such page exists.
          Ken Fyten made changes -
          Assignee Priority P3 P2
          Mark Collette made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          Hide
          Mark Collette added a comment -

          Ok, so first off, it is indeed possible to make JSF give a 404 error page, complete with the HTTP header 404 error code.

          In D2DFaceletViewHandler.java, around line 305, just insert the FileNotFoundException trapping before the Exception trapping, and add the handleFaceletFileNotFoundException(FacesContext) method:

          catch(FileNotFoundException e)

          { handleFaceletFileNotFoundException(context); }

          catch (Exception e) {
          if (log.isErrorEnabled())

          { log.error("Problem in renderResponse: " + e.getMessage(), e); }

          throw new FacesException("Problem in renderResponse: " + e.getMessage(), e);
          }
          }

          protected void handleFaceletFileNotFoundException(FacesContext context)
          throws FacesException, IOException {
          String actualId = "";
          UIViewRoot viewToRender = context.getViewRoot();
          if( viewToRender != null)

          { String viewId = viewToRender.getViewId(); String renderedViewId = getRenderedViewId(context, viewId); actualId = getActionURL(context, renderedViewId); }

          Object respObj = context.getExternalContext().getResponse();
          if (respObj instanceof HttpServletResponse)

          { HttpServletResponse respHttp = (HttpServletResponse) respObj; respHttp.sendError(HttpServletResponse.SC_NOT_FOUND, actualId); context.responseComplete(); }

          }

          But, it raises two main issues:

          1. What do we do for Portlets? This solution specifically uses the HttpServletResponse. Now Deryk says that his portlet response object will act like a servlet one too, but you can't set headers in portlets. So are we wanting it to just server out some 404-esque HTML snippet? Wouldn't we want that to be user configurable?

          2. Which brings us to ICE-1133, which addresses catching Exceptions, and forwarding/redirecting to application developer specified pages. The problem is, if I catch the FileNotFoundException to send out the 404, then that will circumvent the Exception/500 code mechanism. To complicate matters, the FileNotFoundException is being wrapped in a FacesException, and the code is not pulling out the causing exception, so application developers can't, as of right now, actually specifically trap FileNotFoundException with the ICE-1133 method.

          Show
          Mark Collette added a comment - Ok, so first off, it is indeed possible to make JSF give a 404 error page, complete with the HTTP header 404 error code. In D2DFaceletViewHandler.java, around line 305, just insert the FileNotFoundException trapping before the Exception trapping, and add the handleFaceletFileNotFoundException(FacesContext) method: catch(FileNotFoundException e) { handleFaceletFileNotFoundException(context); } catch (Exception e) { if (log.isErrorEnabled()) { log.error("Problem in renderResponse: " + e.getMessage(), e); } throw new FacesException("Problem in renderResponse: " + e.getMessage(), e); } } protected void handleFaceletFileNotFoundException(FacesContext context) throws FacesException, IOException { String actualId = ""; UIViewRoot viewToRender = context.getViewRoot(); if( viewToRender != null) { String viewId = viewToRender.getViewId(); String renderedViewId = getRenderedViewId(context, viewId); actualId = getActionURL(context, renderedViewId); } Object respObj = context.getExternalContext().getResponse(); if (respObj instanceof HttpServletResponse) { HttpServletResponse respHttp = (HttpServletResponse) respObj; respHttp.sendError(HttpServletResponse.SC_NOT_FOUND, actualId); context.responseComplete(); } } But, it raises two main issues: 1. What do we do for Portlets? This solution specifically uses the HttpServletResponse. Now Deryk says that his portlet response object will act like a servlet one too, but you can't set headers in portlets. So are we wanting it to just server out some 404-esque HTML snippet? Wouldn't we want that to be user configurable? 2. Which brings us to ICE-1133 , which addresses catching Exceptions, and forwarding/redirecting to application developer specified pages. The problem is, if I catch the FileNotFoundException to send out the 404, then that will circumvent the Exception/500 code mechanism. To complicate matters, the FileNotFoundException is being wrapped in a FacesException, and the code is not pulling out the causing exception, so application developers can't, as of right now, actually specifically trap FileNotFoundException with the ICE-1133 method.
          Mark Collette made changes -
          Fix Version/s 1.6.1 [ 10070 ]
          Fix Version/s 1.6 [ 10031 ]
          Ken Fyten made changes -
          Link This issue depends on ICE-1133 [ ICE-1133 ]
          Ken Fyten made changes -
          Fix Version/s 1.6 [ 10031 ]
          Fix Version/s 1.6.1 [ 10070 ]
          Assignee Priority P2
          Assignee Mark Collette [ mark.collette ]
          Ken Fyten made changes -
          Status In Progress [ 3 ] Closed [ 6 ]
          Resolution Duplicate [ 3 ]
          Hide
          Nir Geier added a comment -

          hi,

          When i look for page that does not exists (V1.53) this is the exact exception.
          after migrating to V1.6 i get null pointer exception (error code : 500) and not 404.

          if this the fix that was made (throw null pointer exception and not 404)?

          Show
          Nir Geier added a comment - hi, When i look for page that does not exists (V1.53) this is the exact exception. after migrating to V1.6 i get null pointer exception (error code : 500) and not 404. if this the fix that was made (throw null pointer exception and not 404)?
          Hide
          Mark Collette added a comment -

          Sorry Nir, but no code change was made. I think that we're aiming for people to use the mechanism that ICE-1133 introduces. Basically, you can define error handler pages for each Exception type, including this specific FileNotFoundException.

          Show
          Mark Collette added a comment - Sorry Nir, but no code change was made. I think that we're aiming for people to use the mechanism that ICE-1133 introduces. Basically, you can define error handler pages for each Exception type, including this specific FileNotFoundException.

            People

            • Assignee:
              Unassigned
              Reporter:
              Mark Collette
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: