PDF Space Export never completes for large Confluence spaces

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Exporting a Confluence Space with thousands of pages to PDF runs indefinitely. 

Diagnosis

The PDF space export on the Confluence web UI hangs at 99% completion. Confluence application logs show the following error:

1 2 3 4 5 6 7 8 2023-08-29 10:25:28,151 ERROR [Long running task: PDF Space Export] [confluence.util.longrunning.ConfluenceAbstractLongRunningTask] run Long running task "PDF Space Export" failed to run. -- url: /confluence/spaces/flyingpdf/doflyingpdf.action | referer: https://confluence.atlassian.test/confluence/spaces/flyingpdf/flyingpdf.action?key=TROL | traceId: b38cee07ad805b93 | userName: admin | action: doflyingpdf java.lang.StackOverflowError at java.base/java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:73) at jdk.internal.reflect.GeneratedMethodAccessor1481.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566)

This error can be addressed by increasing the Java stack size to 8MB. Once this setting is applied and the PDF space export is attempted again, unfortunately there will be another failure which will not state a clear reason:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2023-08-29 11:01:08,727 ERROR [Long running task: PDF Space Export] [core.task.longrunning.AbstractLongRunningTask] lambda$doRunInternal$0 Error during PDF export -- url: /confluence/spaces/flyingpdf/doflyingpdf.action | referer: https://confluence.atlassian.test/confluence/spaces/flyingpdf/flyingpdf.action?key=TROL | traceId: b659c6e71ea0efe0 | userName: admin | action: doflyingpdf com.atlassian.confluence.importexport.ImportExportException: We couldn't complete your export. There was an error converting the page "Table of contents". <a href="https://docs.atlassian.com/confluence/docs-719/PDF+export+in+Confluence+Data+Center">Learn more</a> [...] Caused by: com.atlassian.confluence.util.sandbox.SandboxCrashedException: Sandbox has crashed while serving the request at com.atlassian.confluence.impl.util.sandbox.SandboxProcess.tryToThrowSpecificException(SandboxProcess.java:174) at com.atlassian.confluence.impl.util.sandbox.SandboxProcess.execute(SandboxProcess.java:139) at com.atlassian.confluence.impl.util.sandbox.SandboxLocalProcessPool.execute(SandboxLocalProcessPool.java:107) at com.atlassian.confluence.impl.util.sandbox.ConfluenceSandboxPoolFactory$LazySandbox.execute(ConfluenceSandboxPoolFactory.java:70) at com.atlassian.confluence.impl.util.sandbox.DefaultSandbox.execute(DefaultSandbox.java:36) at com.atlassian.confluence.extra.flyingpdf.sandbox.PdfExportSandbox.execute(PdfExportSandbox.java:49) at com.atlassian.confluence.extra.flyingpdf.sandbox.SandboxXmlToPdfConverter.convertXhtmlToPdf(SandboxXmlToPdfConverter.java:83) ... 57 more Caused by: java.io.EOFException at java.base/java.io.DataInputStream.readInt(DataInputStream.java:397) at com.atlassian.confluence.impl.util.sandbox.SandboxMessage.receiveMessage(SandboxMessage.java:43) at com.atlassian.confluence.impl.util.sandbox.SandboxProcess.receiveMessage(SandboxProcess.java:227) at com.atlassian.confluence.impl.util.sandbox.SandboxProcess.execute(SandboxProcess.java:136)

To understand why the conversion sandbox process failed the package com.atlassian.confluence.impl.util.sandbox need to be set at DEBUG level. After increasing the logging level and repeating the PDF space export, Confluence application logs will show the error that made the sandbox process crash:

1 2 3 2023-08-29 11:23:44,352 INFO [sandbox-logger] [impl.util.sandbox.ConversionSandbox] lambda$buildConfig$0 worker0: Exception in thread "main" java.lang.StackOverflowError 2023-08-29 11:23:44,352 INFO [sandbox-logger] [impl.util.sandbox.ConversionSandbox] lambda$buildConfig$0 worker0: at java.base/java.io.ObjectInputStream.readHandle(ObjectInputStream.java:1801) 2023-08-29 11:23:44,352 INFO [sandbox-logger] [impl.util.sandbox.ConversionSandbox] lambda$buildConfig$0 worker0: at java.base/java.io.ObjectInputStream.readClassDesc(ObjectInput

The reason of the sandbox process failure is again a StackOverflowError, this happens because the sandbox process does not inherit the stack size setting from Confluence and need the property conversion.sandbox.stack.limit.megabytes to be set accordingly.

Cause

The serialisation of the pages in the space exceed the Confluence Java Stack default size of 2MB.

Solution

Increase the Java stack size for both Confluence and the conversion Sandbox process by adding the following Java System properties:

1 -Xss8m -Dconversion.sandbox.stack.limit.megabytes=8

and then rolling restart all Confluence nodes in the cluster.

Please be aware that 8MB for the Java Stack size helped with a space with around 3700 pages. A different value may be a better setting for a space of different size.

Updated on March 20, 2025

Still need help?

The Atlassian Community is here for you.