Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-22045

Fix incorrect error management blocking Tomcat threads

    XMLWordPrintable

    Details

      Description

      If a servlet causes a runtime exception, the error recovery behaves incorrectly and causes the thread context to be in a state from which Tomcat does not recover automatically.

      The recurring error is:

      ERROR [DefaultNuxeoExceptionHandler] java.lang.NullPointerException
      	at org.apache.catalina.connector.Request.getServletContext(Request.java:1655)
      	at org.apache.catalina.connector.Request.getContextPath(Request.java:2013)
      	at org.apache.catalina.connector.RequestFacade.getContextPath(RequestFacade.java:785)
      	at org.nuxeo.ecm.platform.web.common.vh.VirtualHostHelper.getContextPath(VirtualHostHelper.java:175)
      	at org.nuxeo.ecm.platform.web.common.vh.VirtualHostHelper.getWebAppName(VirtualHostHelper.java:67)
      	at org.nuxeo.ecm.platform.ui.web.util.BaseURL.getWebAppName(BaseURL.java:62)
      	at org.nuxeo.ecm.platform.ui.web.util.BaseURL.getLocalBaseURL(BaseURL.java:80)
      	at org.nuxeo.ecm.platform.ui.web.rest.services.URLPolicyServiceImpl.getDocumentViewFromRequest(URLPolicyServiceImpl.java:251)
      	at org.nuxeo.ecm.platform.ui.web.rest.services.URLPolicyServiceImpl.getURLPatternDescriptor(URLPolicyServiceImpl.java:196)
      	at org.nuxeo.ecm.platform.ui.web.rest.services.URLPolicyServiceImpl.isCandidateForDecoding(URLPolicyServiceImpl.java:142)
      

      As well as a followup exception:

      12:47:56,454 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
      java.lang.NullPointerException
      	at org.jboss.seam.mock.MockExternalContext$3.getAttribute(MockExternalContext.java:388)
      	at org.jboss.seam.mock.MockExternalContext$AttributeMap.get(MockExternalContext.java:412)
      	at org.jboss.seam.contexts.ServerConversationContext.get(ServerConversationContext.java:103)
      	at org.jboss.seam.contexts.Contexts.lookupInStatefulContexts(Contexts.java:228)
      	at org.jboss.seam.Component.getInstance(Component.java:1996)
      	at org.jboss.seam.Component.getInstance(Component.java:1991)
      	at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
      	at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
      	at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:148)
      	at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:51)
      	at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
      	at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
      	at com.sun.faces.el.ChainTypeCompositeELResolver.getValue(ChainTypeCompositeELResolver.java:90)
      	at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:90)
      	at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:71)
      	at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
      	at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:950)
      	at org.apache.jsp.nuxeo_005ferror_jsp._jspx_meth_c_005fout_005f0(nuxeo_005ferror_jsp.java:321)
      	at org.apache.jsp.nuxeo_005ferror_jsp._jspService(nuxeo_005ferror_jsp.java:203)
      	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
      	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
      	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
      

      This error happens if for an instance a null is returned from blob.getStream() in the DownloadServiceImpl. This immediately causes a NullPointerException which is caught by DefaultNuxeoExceptionHandler.handleException which calls requestDispatcher.forward to generate the JSP error page. However JSP page rendering fails because even though response.isCommitted() == false, we have org.apache.catalina.connector.Response.usingOutputStream == true which prevents JSP from acquiring a PrintWriter. This error in error leaves the FacesContext.getCurrentInstance().getExternalContext().getRequest() in a state without a context which is reused by the next user of the same thread, which fails with the above stack trace.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day
                  1d