PDF exports are failing with a 'java is not an executable' error

Still need help?

The Atlassian Community is here for you.

Ask the community

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

PDF exports are failing with a "java is not an executable" error on Confluence Data Center after a JDK change:



Environment

Confluence Data Center (6.10 and newer, 7.x and 8.x)


Diagnosis

1. PDF exports are failing with the following error:

Caused by: com.atlassian.confluence.util.sandbox.SandboxException: /opt/jdk/jdk8u332-b09/jre/bin/java is not an executable

PS: for instances hosted on Windows Server, a similar "java.exe is not an executable" error will be displayed.


2. The directory mentioned in $JAVA_HOME is not available at the server:

$ sudo su - confluence

$ echo $JAVA_HOME
/opt/jdk/jdk8u332-b09/jre

$ cd $JAVA_HOME
cd: no such file or directory: /opt/jdk/jdk8u332-b09/jre


3. The following error is displayed in <Confluence-Home>/logs/atlassian-confluence.log:

2022-12-20 14:22:08,583 ERROR [http-nio-127.0.0.1-8090-exec-182] [atlassian.confluence.servlet.ConfluenceServletDispatcher] sendError Could not execute action
 -- url: /spaces/flyingpdf/pdfpageexport.action | traceId: 101bf951f8e1603f | userName: charlie | referer: https://charlie.confluence.com/display/CHARLIE/SamplePage
java.lang.RuntimeException: com.atlassian.confluence.importexport.ImportExportException: We couldn't complete your export. There was an error converting the page "SamplePage". <a href="https://docs.atlassian.com/confluence/docs-718/PDF+export+in+Confluence+Data+Center">Learn more</a>
	at com.atlassian.confluence.extra.flyingpdf.impl.ExportPageAsPdfAction.doExecute(ExportPageAsPdfAction.java:58)
	at com.atlassian.confluence.extra.flyingpdf.impl.PdfExportSemaphore.run(PdfExportSemaphore.java:28)
	at com.atlassian.confluence.extra.flyingpdf.impl.ExportPageAsPdfAction.execute(ExportPageAsPdfAction.java:31)
        ...
Caused by: com.atlassian.confluence.importexport.ImportExportException: We couldn't complete your export. There was an error converting the page "SamplePage". <a href="https://docs.atlassian.com/confluence/docs-718/PDF+export+in+Confluence+Data+Center">Learn more</a>
	at com.atlassian.confluence.extra.flyingpdf.sandbox.SandboxXmlToPdfConverter.convertXhtmlToPdf(SandboxXmlToPdfConverter.java:108)
	at com.atlassian.confluence.extra.flyingpdf.sandbox.SandboxPdfExporterService.renderPdf(SandboxPdfExporterService.java:348)
	at com.atlassian.confluence.extra.flyingpdf.sandbox.SandboxPdfExporterService.createPdf(SandboxPdfExporterService.java:334)
        ...
	... 415 more
Caused by: com.atlassian.confluence.util.sandbox.SandboxException: /opt/jdk/jdk8u332-b09/jre/bin/java is not an executable
	at com.atlassian.confluence.impl.util.sandbox.SandboxProcess.getJavaRuntime(SandboxProcess.java:330)
	at com.atlassian.confluence.impl.util.sandbox.SandboxProcess.start(SandboxProcess.java:254)

Cause

Java is not available at the defined $JAVA_HOME location, so the External Process Pool (also known as "Sandbox") fails to start with the above error.

This is most likely caused by a Java update (eg. Java 8 to 11) where the old version is removed from the server but Confluence was not restarted.

It is also possible that the Java directory was moved or deleted after Confluence was started up.

Solution

Restart Confluence.

Once done, confirm if $JAVA_HOME is updated with the new Java path:

$ sudo su - confluence

$ echo $JAVA_HOME
/opt/jdk/jdk11.0.14.1/jre

$ $JAVA_HOME/bin/java -version
OpenJDK Runtime Environment Temurin-11.0.14.1+1 (build 11.0.14.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.14.1+1 (build 11.0.14.1+1, mixed mode)


Workaround

Restarting Confluence during business hours may cause unwanted downtime, so here's a few options:

1. Temporarily restore the deleted Java version to the original $JAVA_HOME path on the server.

PS: Once Confluence gets restarted and the $JAVA_HOME variable is updated, the old Java version can be deleted again.

2. Manually update the $JAVA_HOME variable with the new Java path:

$ sudo su - confluence

$ echo $JAVA_HOME
/opt/jdk/jdk8u332-b09/jre

$ JAVA_HOME=/opt/jdk/jdk11.0.14.1/jre

$ echo $JAVA_HOME
/opt/jdk/jdk11.0.14.1/jre



Last modified on Dec 28, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.