Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-9659

PDF space export failing in Resin 3.x due to incorrect handling of HttpServletRequest

    XMLWordPrintable

Details

    Description

      This problem is raised from the support issue - https://support.atlassian.com/browse/CSP-11863

      The initial problem was a failure during PDF export which looked like -

      2007-10-03 21:26:09,006 ERROR [Export Space task] [core.task.longrunning.AbstractLongRunningTask] doInTransactionWithoutResult 
      Error during export
       -- url: /spaces/doexportspace.action | userName: pcurren | action: doexportspace
      com.atlassian.confluence.importexport.ImportExportException: java.lang.NullPointerException
              at com.atlassian.confluence.importexport.impl.PdfExporter.generateXslFo(PdfExporter.java:178)
              at com.atlassian.confluence.importexport.impl.PdfExporter.doExportEntity(PdfExporter.java:97)
              at com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.exportSpace(AbstractRendererExporterImpl.java:127)
              at com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.doExport(AbstractRendererExporterImpl.java:109)
              at com.atlassian.confluence.importexport.impl.PdfExporter.doExport(PdfExporter.java:63)
              at com.atlassian.confluence.importexport.DefaultImportExportManager.exportAs(DefaultImportExportManager.java:112)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
              at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
              at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
              at $Proxy49.exportAs(Unknown Source)
              at com.atlassian.confluence.importexport.actions.ExportSpaceLongRunningTask$2.doInTransactionWithoutResult(ExportSpaceLongRunningTask.java:8
      5)
              at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33)
              at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:114)
              at com.atlassian.confluence.importexport.actions.ExportSpaceLongRunningTask.runInternal(ExportSpaceLongRunningTask.java:61)
              at com.atlassian.confluence.util.longrunning.ConfluenceAbstractLongRunningTask.run(ConfluenceAbstractLongRunningTask.java:21)
              at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.NullPointerException
              at com.caucho.server.connection.AbstractHttpRequest.getContextPath(AbstractHttpRequest.java:506)
              at javax.servlet.http.HttpServletRequestWrapper.getContextPath(HttpServletRequestWrapper.java:108)
              at javax.servlet.http.HttpServletRequestWrapper.getContextPath(HttpServletRequestWrapper.java:108)
              at javax.servlet.http.HttpServletRequestWrapper.getContextPath(HttpServletRequestWrapper.java:108)
              at javax.servlet.http.HttpServletRequestWrapper.getContextPath(HttpServletRequestWrapper.java:108)
              at javax.servlet.http.HttpServletRequestWrapper.getContextPath(HttpServletRequestWrapper.java:108)
              at com.caucho.server.webapp.RequestDispatcherImpl.include(RequestDispatcherImpl.java:403)
              at com.caucho.server.webapp.RequestDispatcherImpl.include(RequestDispatcherImpl.java:350)
              at com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.exportResource(AbstractRendererExporterImpl.java:208)
              at com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.exportImages(AbstractRendererExporterImpl.java:151)
              at com.atlassian.confluence.importexport.impl.PdfExporter.generateXslFo(PdfExporter.java:174)
              ... 22 more
      

      This is due to the HttpServletRequest instance being stored within the ThreadLocal and accessed by the LongRunningTask thread as it performed the export. When resin returns the HttpServletRequest to the pool some internal details are nulled (such as the context).

      This was worked around by wrapping the request in a compatible class which takes a copy of the necessary data.

      The ServletContextHoldingRequest also needed to be modified. It was returning an HttpSession instance anonymous class which resin was later trying to cast to it's own SessionImpl class. (ServletContextHoldingRequest was modified to hold the HttpSession instance from the real request.)

      Once this was all hacked around, a new problem was being exposed -

      2007-10-08 13:26:57,004 ERROR [Export Space task] [core.task.longrunning.AbstractLongRunningTask] doInTransactionWithoutResult Error during export
       -- url: /spaces/doexportspace.action | userName: pcurren | action: doexportspace
      com.atlassian.confluence.importexport.ImportExportException: Error while generating PDF!
              at com.atlassian.confluence.importexport.impl.PdfExporter.foToPdf(PdfExporter.java:137)
              at com.atlassian.confluence.importexport.impl.PdfExporter.doExportEntity(PdfExporter.java:98)
              at com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.exportSpace(AbstractRendererExporterImpl.java:127)
              at com.atlassian.confluence.importexport.impl.AbstractRendererExporterImpl.doExport(AbstractRendererExporterImpl.java:109)
              at com.atlassian.confluence.importexport.impl.PdfExporter.doExport(PdfExporter.java:63)
              at com.atlassian.confluence.importexport.DefaultImportExportManager.exportAs(DefaultImportExportManager.java:112)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
              at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
              at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
              at $Proxy49.exportAs(Unknown Source)
              at com.atlassian.confluence.importexport.actions.ExportSpaceLongRunningTask$2.doInTransactionWithoutResult(ExportSpaceLongRunningTask.java:87)
              at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33)
              at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:114)
              at com.atlassian.confluence.importexport.actions.ExportSpaceLongRunningTask.runInternal(ExportSpaceLongRunningTask.java:63)
              at com.atlassian.confluence.util.longrunning.ConfluenceAbstractLongRunningTask.run(ConfluenceAbstractLongRunningTask.java:21)
              at java.lang.Thread.run(Thread.java:613)
      Caused by: javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: file:///Users/pcurren/Atlassian/data/confluence/cac/temp/export_10082007_131342/CONF256-20071008-13_13_42.fo:16961:0: Error(16961/0): fo:list-block is missing child elements. 
      Required Content Model: marker* (list-item)+
              at com.icl.saxon.IdentityTransformer.transform(IdentityTransformer.java:61)
              at com.atlassian.confluence.importexport.impl.PdfExporter.foToPdf(PdfExporter.java:132)
              ... 22 more
      Caused by: org.apache.fop.fo.ValidationException: file:///Users/pcurren/Atlassian/data/confluence/cac/temp/export_10082007_131342/CONF256-20071008-13_13_42.fo:16961:0: Error(16961/0): fo:list-block is missing child elements. 
      Required Content Model: marker* (list-item)+
              at org.apache.fop.fo.FONode.missingChildElementError(FONode.java:408)
              at org.apache.fop.fo.flow.ListBlock.endOfNode(ListBlock.java:105)
              at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:379)
              at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:195)
              at com.caucho.xml.XmlParser.addElement(XmlParser.java:2608)
              at com.caucho.xml.XmlParser.parseElement(XmlParser.java:641)
              at com.caucho.xml.XmlParser.parseNode(XmlParser.java:367)
              at com.caucho.xml.XmlParser.parseInt(XmlParser.java:242)
              at com.caucho.xml.AbstractParser.parse(AbstractParser.java:633)
              at com.icl.saxon.IdentityTransformer.transform(IdentityTransformer.java:59)
              ... 23 more
      

      At this point, I've decided to resolved the support request in a different way, and gift these three problems to the bug fix team

      Attachments

        Issue Links

          Activity

            People

              pcurren Paul Curren
              pcurren Paul Curren
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: