I am unable to export a space as a PDF
Asked by fmarcaccio:

I am trying to export a space as a PDF.  
The export process starts, then the following error occurs: "Ha fallito durante l'esportazione a PDF. Messaggio di eccezione - java.lang.NullPointerException", in English: "It has failed during the PDF export. Exception message: java.lang.NullPointerException ".


Answers:
author: AnnWorley
body: So the error this time is:

```
RuntimeException error occurred while performing an XHTML storage transformation
```

I found an article that says something like this can be caused by running Java 1.8 on MS Windows server 2003: [RuntimeException error occurred while performing an XHTML storage transformation](https://confluence.atlassian.com/confkb/runtimeexception-error-occurred-while-performing-an-xhtml-storage-transformation-831750529.html)

Does this apply to your instance?

comments: author: fmarcaccio
body: Unfortunately not. I am running Java 8 on a Linux server. The distribution is Centos version 7


author: AnnWorley
body: So that we can take a closer look, I created a support ticket using the email address you are using for Community. You will receive a confirmation email from atlassian.com with your ticket details within the next few minutes. When the issue has been resolved we can circle back to let the Community know what the fix is.


author: AnnWorley
body: Hi Francesco.

I understand a null pointer exception error is seen in the browser when you export a space to PDF. This has been seen in the past due to third party plugins that render ok but don't export well. If you can post the rest of the stack trace it may give us an idea which plugin.

The [Tracking Plugin](https://marketplace.atlassian.com/plugins/net.customware.confluence.plugin.tracking/server/overview) has been known to cause a similar issue:[NullPointerException exporting a page or space to PDF due to Tracking-Table Macro](https://confluence.atlassian.com/confkb/nullpointerexception-exporting-a-page-or-space-to-pdf-due-to-tracking-table-macro-129171508.html)

I look forward to hearing what you find.

Thanks,

Ann

comments: author: fmarcaccio
body: Hi Ann, thank you for your reply.  
My issue is that I am unable to view the stack trace for this exception. I took a look at the Catalina log files, but I can't see this exception (while I can see the trace of other unrelated exception). I also tried to increase the log verbosity using the Administrative panel Confluence offer me (i haven't tried to increase the Log4J verbosity directly).

Can you point me where this trace is?

Thank you for your support  
Best regards  
Francesco


author: Nic Brough -Adaptavist-
body: The errors should be going into the application log - look in system information to see where that is (the default is a set of files in \<confluence home\>/logs/ )


author: fmarcaccio
body: Hi Nick, thanks for your reply.  
I've done a text search in the logs directory for the word "NullPointerException" without any luck


author: AnnWorley
body: For testing troubleshooting purposes, please try [Disabling or enabling all add-ons (using Safe Mode)](https://confluence.atlassian.com/upm/disabling-and-enabling-add-ons-273875716.html#Disablingandenablingadd-ons-Disablingorenablingalladd-ons(usingSafeMode)) and export the space to PDF while in safe mode. *Note: Any macros that depend on user installed plugins will be disabled while the instance is in safe mode so you will want to do it during off hours or a maintenance window.*

If the export works in safe mode, then you can re-enable the add-ons one by one until the export breaks, in order to see which one is causing the issue.


author: fmarcaccio
body: Hi Ann. I just tried what you suggest, but I get the same error as before. If it can help you, I don't have any plugin installed. I just use the default Confluence installation


author: fmarcaccio
body: Hi Ann, if it can help you, i just found the Confluence dir. It was under /var even if in the settings i specified to save them in the confluence home /log. Anyway, here there are (i replaced my real domain with http://host)

<https://pastebin.com/edsMkNgc>


author: fmarcaccio
body: I just removed all Jira tasks from the space. Now i am able to export a single page in PDF. If i try to export the whole space, the NullPointerException comes again, this time with a different trace.  
Here you can find it

<br />

<https://pastebin.com/Tp6C7CBZ>


author: AnnWorley
body: It does help! Thank you very much for the log. It looks like Jira issues macros are causing the null pointer exception during PDF exports:

```
2017-10-23 20:01:20,899 ERROR [Long running task: PDF Space Export] [xhtml.view.macro.ViewMacroMarshaller] handleMacroExecutionException Error rendering macro: jira
-- url: /spaces/flyingpdf/doflyingpdf.action | referer: http://host:8090/spaces/flyingpdf/flyingpdf.action?key=SPED | traceId: 78afd2847c7b36c8 | userName: f.marcaccio | action: doflyingpdf
java.lang.NullPointerException
```

Please let me know if the Jira issues macros are displaying on the pages as expected before the export. (I am looking for reasons why the PDF export cannot render those macros.)

I found some bug reports with Jira issues and PDF exports, but none that really match our case, so I am optimistic that we are not running into a bug.

Edit - Our comments crossed, I will look at the new log now.