Uploaded image for project: 'Confluence Cloud'
  1. Confluence Cloud
  2. CONFCLOUD-25278

Page margin CSS in PDF Stylesheet can OOME and cause high load on Confluence during PDF export

XMLWordPrintable

      NOTE: This bug report is for Confluence Cloud. Using Confluence Server? See the corresponding bug report.

      Steps to reproduce:
      1. Add the following CSS in your Space PDF Stylesheet:
        @page 
        {
            margin: 5.5in;
        }
        
      2. Export a Page to PDF and will ended up at System Error page with the following stacktrace:
        2012-04-19 17:22:06,698 ERROR [http-8080-3] [[Standalone].[localhost].[/confluence].[action]] log Servlet.service() for servlet action threw exception
        java.lang.OutOfMemoryError: Java heap space
            at java.util.LinkedList.addBefore(LinkedList.java:778)
            at java.util.LinkedList.add(LinkedList.java:198)
            at org.xhtmlrenderer.css.newmatch.CascadedStyle.addProperties(CascadedStyle.java:148)
            at org.xhtmlrenderer.css.newmatch.CascadedStyle.<init>(CascadedStyle.java:135)
            at org.xhtmlrenderer.css.newmatch.Matcher.getPageCascadedStyle(Matcher.java:121)
            at org.xhtmlrenderer.context.StyleReference.getPageStyle(StyleReference.java:203)
            at org.xhtmlrenderer.layout.Layer.createPageBox(Layer.java:794)
            at org.xhtmlrenderer.layout.Layer.addPage(Layer.java:764)
            at org.xhtmlrenderer.layout.Layer.addPagesUntilPosition(Layer.java:875)
            at org.xhtmlrenderer.layout.Layer.getPage(Layer.java:861)
            at org.xhtmlrenderer.layout.Layer.getFirstPage(Layer.java:805)
            at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:774)
            at org.xhtmlrenderer.render.BlockBox.layout(BlockBox.java:735)
            at org.xhtmlrenderer.pdf.ITextRenderer.layout(ITextRenderer.java:209)
            at com.atlassian.confluence.extra.flyingpdf.FlyingSaucerXmlToPdfConverter.convertXhtmlToPdf(FlyingSaucerXmlToPdfConverter.java:92)
            at com.atlassian.confluence.extra.flyingpdf.FlyingSaucerXmlToPdfConverter.convertXhtmlToPdf(FlyingSaucerXmlToPdfConverter.java:38)
            at com.atlassian.confluence.extra.flyingpdf.FlyingSaucerPdfExporterService.createPdfForPage(FlyingSaucerPdfExporterService.java:78)
            at com.atlassian.confluence.extra.flyingpdf.ExportPageAsPdfAction.execute(ExportPageAsPdfAction.java:28)
            at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:168)
            at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
            at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
            at com.opensymphony.xwork.interceptor.DefaultWorkflowInterceptor.intercept(DefaultWorkflowInterceptor.java:55)
            at com.atlassian.confluence.core.ConfluenceWorkflowInterceptor.intercept(ConfluenceWorkflowInterceptor.java:37)
            at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
            at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
            at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
            at com.atlassian.xwork.interceptors.XsrfTokenInterceptor.intercept(XsrfTokenInterceptor.java:100)
            at com.atlassian.confluence.xwork.ConfluenceXsrfTokenInterceptor.intercept(ConfluenceXsrfTokenInterceptor.java:25)
            at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
            at com.atlassian.confluence.security.interceptors.CaptchaInterceptor.intercept(CaptchaInterceptor.java:49)
            at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
            at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35) 
        
      3. Export the Space to PDF and it will take forever and throw the following in the stacktrace:
        2012-04-19 17:02:40,878 ERROR [Long running task: PDF Space Export] [content.render.xhtml.DefaultRenderer] render Error rendering content for view: RuntimeException occurred while performing an XHTML storage transformation (null)
         -- referer: http://localhost:8080/confluence/spaces/flyingpdf/flyingpdf.action?key=SBX | url: /confluence/spaces/flyingpdf/doflyingpdf.action | userName: admin | action: doflyingpdf
        com.atlassian.confluence.content.render.xhtml.XhtmlException: RuntimeException occurred while performing an XHTML storage transformation (null)
            at com.atlassian.confluence.content.render.xhtml.storage.StorageXhtmlTransformer.transform(StorageXhtmlTransformer.java:60)
            at com.atlassian.confluence.content.render.xhtml.TransformerChain.transform(TransformerChain.java:41)
            at com.atlassian.confluence.content.render.xhtml.PluggableTransformerChain.transform(PluggableTransformerChain.java:53)
            at com.atlassian.confluence.content.render.xhtml.DefaultRenderer.render(DefaultRenderer.java:63)
            at com.atlassian.confluence.content.render.xhtml.DefaultRenderer.render(DefaultRenderer.java:51)
            at com.atlassian.confluence.extra.flyingpdf.html.RenderedXhtmlBuilder.renderToHtml(RenderedXhtmlBuilder.java:377)
            at com.atlassian.confluence.extra.flyingpdf.html.RenderedXhtmlBuilder.renderContentTreeNodes(RenderedXhtmlBuilder.java:346)
            at com.atlassian.confluence.extra.flyingpdf.html.RenderedXhtmlBuilder.buildHtml(RenderedXhtmlBuilder.java:134)
            at com.atlassian.confluence.extra.flyingpdf.FlyingSaucerPdfExporterService.createPdfForSpace(FlyingSaucerPdfExporterService.java:50)
            at com.atlassian.confluence.extra.flyingpdf.PdfExportLongRunningTask$1.doInTransactionWithoutResult(PdfExportLongRunningTask.java:70)
            at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33)
            at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)
            at com.atlassian.confluence.extra.flyingpdf.PdfExportLongRunningTask.runInternal(PdfExportLongRunningTask.java:52)
            at com.atlassian.confluence.util.longrunning.ConfluenceAbstractLongRunningTask.run(ConfluenceAbstractLongRunningTask.java:21)
            at com.atlassian.confluence.util.longrunning.ManagedTask.run(ManagedTask.java:35)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
            at java.util.concurrent.FutureTask.run(FutureTask.java:138)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
            at java.lang.Thread.run(Thread.java:662)
        Caused by: java.lang.NullPointerException
            at com.atlassian.confluence.content.render.xhtml.editor.macro.DefaultPlaceholderUrlFactory.getUrlForErrorPlaceholder(DefaultPlaceholderUrlFactory.java:73)
            at com.atlassian.confluence.content.render.xhtml.transformers.TransformErrorToHtmlPlaceholder.handle(TransformErrorToHtmlPlaceholder.java:54)
            at com.atlassian.confluence.content.render.xhtml.transformers.DefaultFragmentTransformer.transform(DefaultFragmentTransformer.java:124)
            at com.atlassian.confluence.content.render.xhtml.storage.StorageXhtmlTransformer.transform(StorageXhtmlTransformer.java:43)
            ... 20 more
        
      Findings

      It seems that this can only be reproduced if the value of the margin is bigger than 5in.

      Workaround

      Follow the instructions from the following KB article:
      http://confluence.atlassian.com/display/CONFKB/Exporting+Page+or+Space+to+PDF+Fails+and+Causes+High+Load+or+OutOfMemoryError

              Unassigned Unassigned
              halatas HuseinA
              Votes:
              13 Vote for this issue
              Watchers:
              11 Start watching this issue

                Created:
                Updated:
                Resolved: