Jira Core 8.4 problem with displaying PDFs

Jason Adam February 27, 2020

In our Jira, system-user-nav-bar-sections.xml has been updated with the following:

<web-item key="view_core_help" name="View Core help" section="system.user.options/jira-help" weight="450">
<label key="jira.core.help" />
<tooltip key="jira.core.tooltip" />
<link linkId="view_core_help">/filelinks.jsp</link>
<param name="target" value="_blank"/>
<context-provider class="com.atlassian.jira.plugin.webfragment.contextproviders.HelpContextProvider" />

<web-item key="view_admin_help" name="View admin help" section="system.user.options/jira-help" weight="460">
<label key="jira.admin.help" />
<tooltip key="jira.admin.tooltip" />
<link linkId="view_admin_help">/filelinks.jsp</link>
<param name="target" value="_blank"/>
<context-provider class="com.atlassian.jira.plugin.webfragment.contextproviders.HelpContextProvider" />
<condition class="com.atlassian.jira.plugin.webfragment.conditions.IsAdminCondition"/>

 The filelinks.jsp is very straight forward:

<%@ page import="com.atlassian.jira.component.ComponentAccessor" %>
<%@ taglib uri="webwork" prefix="ww" %>
<%@ taglib uri="webwork" prefix="ui" %>
<%@ taglib prefix="page" uri="sitemesh-page" %>
<title>JWST JIRA User Guides</title>
<page:capHide value="IFRAME">
<ui:soy moduleKey="'jira.webresources:soy-templates'" template="'JIRA.Templates.Headers.pageHeader'">
<ui:param name="'mainContent'">
<h1><a href="http://localhost:8080/JIRA-UG.pdf">JWST User Guide</a></h1>
<h1><a href="http://localhost:8080/JIRACORESERVER_8.7.pdf">JIRA Core Server Guide</a></h1>
<h1><a href="http://localhost:8080/ADMINJIRASERVER_8.7.pdf">JIRA Server Admin Guide</a></h1>

We do this because our environment does not have access to the outside world.


In Jira 7.11, these PDFs open perfectly fine, but in Jira 8.4 they come out as garbage.  Like the following:


I've looked at the web.xmls and Tomcat configs and can find nothing that is causing the PDF links to come out like this. 

If you choose to download the file and then open it, it opens fine in the browser.  So it appears to be something with the way the file is being hosted through Jira 8.4, and changed between 7.11. 

Normally we run 8.4 with OpenJDK 11 but I switched it back to Java 8 just in case but that didn't change anything.  I noticed the Tomcat versions are different but a very minor version change so I don't think it has anything to do with that.

Any help would be greatly appreciated!


UPDATE:  So I have been able to host these PDFs successfully in different versions of Tomcat but still not through Jira 8.4 (or 8.7) so I overwrote the tomcat exes and jars in Jira's install with just the base version of Tomcat and now the 8.7 Core PDF displays fine but the Admin PDF and even just a test pdf with simply the word Test in it will not display, they come out with all the garbage.  So what could possibly be installed with Jira 8.4/8.7 that would be causing this?  

The funny thing is if I attach a PDF to an issue and click on it to be displayed, it opens fine, but I know Jira does it's own special magic with attachments.

1 answer

1 accepted

2 votes
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 6, 2020

Hi Jason,

I see that you have created some customizations to Jira Server here in order to be able to serve up some help documentation on your network isolated Jira site.  Sorry to hear that this has been a problem with updated Jira versions.  I don't know the exact details on why this behavior changed. 

I have not encountered this specific type of customization before in Jira Server.  The cause could be that some package was adjusted in order to prevent a potential security vulnerability within Jira.  But honestly, that's just a hunch at this point.

I recreated this same problem with your code in my Jira Server 8.7.1 version.  I tried researching this further to see if I could better understand this problem.  In the process of which, I ran across this related stackoverflow post: Display Pdf in browser using java servlet It certainly looks like the results here are due to the way that Jira is not expecting to host such pdf files in this location, and in turn it makes it look like elements like content-type is not being added to header of this element.  In turn the browser is just trying to render the stream of data it gets without realizing this is a pdf file.  Given the root directory these files are being stored in, and the custom fileslinks.jsp file, I don't expect that any such pdf files served from this location are actually using the Java servlet that other Jira attachments would be able to utilize.

You might be able to implement the solution in that article here to help with the functionality I think you want to see here.  Personally, I've never really been a fan of opening a PDF in browser directly.  Far too often I have had bad browser performance relying on the browser or a browser extension to render that data.  I prefer to download the file first and then open that in whatever my favorite PDF viewing application is. 

To that end, I tweaked the fileslink.jsp file to simply add the 'download' attribute to each 'a' link tag.  It made mine look like this:

<h1><a href="http://localhost:8080/JIRA-UG.pdf" download>JWST User Guide</a></h1>
<h1><a href="http://localhost:8080/JIRACORESERVER_8.7.pdf" download>JIRA Core Server Guide</a></h1>
<h1><a href="http://localhost:8080/ADMINJIRASERVER_8.7.pdf" download>JIRA Server Admin Guide</a></h1>

This just forced my browser to outright download the file instead of try to render it.  W3c notes that this element is only in HTML5, so much older browsers won't honor this, but it appears to at least have support for most modern browsers. I tested this against my Firefox and Chrome which seemed to make it work the way I would prefer.

I hope this helps. 


Jason Adam March 6, 2020

Thank you for the response Andy.  Definitely is a customization and we just do it because our environment does not have any access to the outside world.  Just was odd that it stopped working.

Forcing the download of the file definitely is an option.  We also have other Tomcat servers that we could host these on and just have our help links point there.  So at least there are some options, and I appreciate you verifying it’s not just ours lol.

Luca Andreatta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 16, 2021

Had the same problem and solved putting the pdf under static-assets folder.

Suggest an answer

Log in or Sign up to answer