Getting "java.lang.StackOverflowError" while exporting Space or Pages to PDF
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
Users are unable to export a space or page(s) to PDF, the following error is displayed in the atlassian-confluence.log:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2023-03-14 08:59:30,834 ERROR [ajp-nio2-0.0.0.0-8600-exec-3 url: /spaces/flyingpdf/pdfpageexport.action; user: test] [auditor.common.filter.WebEventsFilter] log Error processing web request
-- url: /spaces/flyingpdf/pdfpageexport.action | referer: <page URL>
javax.servlet.ServletException: Servlet execution threw an exception
...
...
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.StackOverflowError
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
Diagnosis
The complete stack trace of the error mentioned below can be found in the logs:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2023-03-14 08:59:30,834 ERROR [ajp-nio2-0.0.0.0-8600-exec-3 url: /spaces/flyingpdf/pdfpageexport.action; user: test] [auditor.common.filter.WebEventsFilter] log Error processing web request
-- url: /spaces/flyingpdf/pdfpageexport.action | referer: <page url>
javax.servlet.ServletException: Servlet execution threw an exception
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:234)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at com.atlassian.confluence.web.filter.DebugFilter.doFilter(DebugFilter.java:63)
at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:32)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:39)
at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.lambda$doFilter$0(DelegatingPluginFilter.java:57)
at com.enhancera.auditor.common.filter.WebEventsFilter.doFilter(WebEventsFilter.java:100)
at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:62)
...
...
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.StackOverflowError
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
...
...
Cause
The error java.lang.StackOverflowError is a runtime error that usually occurs when the application stack is exhausted and is usually caused by deep or infinite recursion.
Solution
The default Java thread stack size would not be more than 1024 kb, we need to increase this value to fix the issue.
We can check the Java thread stack size by running the command on Unix/Linux-based machines.
1
java -XX:+PrintFlagsFinal -version | grep -w "ThreadStackSize"
Shutdown Confluence
Increase Java thread stack size to 8 mb, for this, we need to add a JVM parameter in <Install directory>/bin/setenv.sh (setenv.bat in case of Windows OS) file.
1
CATALINA_OPTS="-Xss8m ${CATALINA_OPTS}"
Start Confluence.
Was this helpful?