Jira server throws attachmentmodule error in the issue view screen

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

When accessing an issue in a JIRA application, the Attachment web panel failed to load with the following error appears in the screen:

  • Error rendering 'com.atlassian.jira.jira-view-issue-plugin:attachmentmodule'. Please contact your JIRA application administrators.

Sample screenshot of the error:

The following exceptions appears in the atlassian-jira.log:

2013-05-22 19:11:20,980 http-bio-8888-exec-2 ERROR tthenhausen 1151x2x2 1dn8de0 37.201.97.7:65439,0:0:0:0:0:0:0:1 /browse/OX-306[jira.web.component.ModuleWebComponentImpl] An exception occured while rendering the web panel: com.atlassian.jira.jira-view-issue-plugin:attachmentmodule (null)
java.lang.NullPointerException
at com.atlassian.jira.plugin.viewissue.AttachmentBlockContextProvider.shouldExpandAsZip(AttachmentBlockContextProvider.java:195)
at com.atlassian.jira.plugin.viewissue.AttachmentBlockContextProvider.convertToSimpleAttachments(AttachmentBlockContextProvider.java:164)
at com.atlassian.jira.plugin.viewissue.AttachmentBlockContextProvider.getContextMap(AttachmentBlockContextProvider.java:119)
at com.atlassian.jira.plugin.webfragment.CacheableContextProviderDecorator.initContextMap(CacheableContextProviderDecorator.java:70)
at com.atlassian.jira.plugin.webfragment.CacheableContextProviderDecorator.getContextMap(CacheableContextProviderDecorator.java:46)
at com.atlassian.jira.plugin.webfragment.contextproviders.MultiContextProvider.getContextMap(MultiContextProvider.java:99)
at com.atlassian.plugin.web.descriptors.DefaultWebPanelModuleDescriptor$ContextAwareWebPanel.getHtml(DefaultWebPanelModuleDescriptor.java:144)
at com.atlassian.jira.web.component.ModuleWebComponentImpl.renderModule(ModuleWebComponentImpl.java:87)
at com.atlassian.jira.web.component.ModuleWebComponentImpl.renderModuleAndLetNoThrowablesEscape(ModuleWebComponentImpl.java:70)
at com.atlassian.jira.web.component.ModuleWebComponentImpl.renderModule(ModuleWebComponentImpl.java:57) <+3>
at java.lang.reflect.Method.invoke(Unknown Source)
at com.atlassian.plugin.osgi.hostcomponents.impl.DefaultComponentRegistrar$ContextClassLoaderSettingInvocationHandler.invoke(DefaultComponentRegistrar.java:129)
at com.sun.proxy.$Proxy219.renderModule(Unknown Source) <+3> 
[.....]

 

Or java.io.IOException: Permission denied

2016-04-27 17:39:45,674 ajp-bio-8009-exec-591 WARN H141051 1059x927882x6 1b73yqg 172.21.8.243 /secure/AjaxIssueAction!default.jspa [jira.issue.attachment.FileSystemAttachmentDirectoryAccessor] Unable to make thumbnail directory /data/JIRA/Home-Main/data/attachments/ACSCLOUD/ACSCLOUD-3868/thumbs
2016-04-27 17:39:45,674 ajp-bio-8009-exec-591 ERROR H141051 1059x927882x6 1b73yqg 172.21.8.243 /secure/AjaxIssueAction!default.jspa [jira.web.component.ModuleWebComponentImpl] An exception occured while rendering the web panel: com.atlassian.jira.jira-view-issue-plugin:attachmentmodule (null)
java.lang.IllegalStateException: java.io.IOException: Permission denied
	at com.atlassian.jira.issue.thumbnail.DefaultThumbnailManager.getTempFile(DefaultThumbnailManager.java:337)

Causes

  • One cause was fixed in JIRA 6.1 and later.  This bug resulted in null values in the mimetype column of the fileattachment table:  JRA-29357 - Getting issue details... STATUS  
  • There is also a known defect in older versions of the third-party JIRA Python Library which was not setting the right mime type for attachments added via REST API.

Resolution 1

Use this SQL to verify this is the problem you're having:

SELECT *
FROM fileattachment
WHERE mimetype IS NULL;

If results are returned there are attachments with NULL for their mimetype that can be fixed.

Always back up your data before performing any modification to the database. If possible, try your modifications on a test server.

First, list all file extensions for attachments with no mime type:

Postgres
SELECT DISTINCT
  count(*) as occurrences,
  substring(filename from '\.(?!.*\.).*$') AS extension
FROM fileattachment
WHERE mimetype IS NULL OR mimetype = ''
GROUP BY extension
ORDER BY extension;
MySQL
SELECT DISTINCT
  count(*) as occurrences,
  substring_index(filename, '.', -1) AS extension
FROM fileattachment
WHERE mimetype IS NULL OR mimetype = ''
ORDER BY extension;

Once you choose appropriate MIME types for all the broken attachments you can fix them. Here's an example for GIF images, modify it for each MIME type you determine from the file extensions.

Postgres
UPDATE fileattachment
SET mimetype = 'image/gif'
WHERE mimetype IS NULL OR mimetype = ''
  AND substring(filename from '\.(?!.*\.).*$') = 'gif';
MySQL
UPDATE fileattachment
SET mimetype = 'image/gif'
WHERE mimetype IS NULL OR mimetype = ''
  AND substring_index(filename, '.', -1) = 'gif';

NOTE: Some attachment file names won't have a "dot three" extension in the name. These must be reviewed one at a time to determine the correct MIME type. Alternatively, you could set mimetype to "text/plain" for these files so they can be downloaded and fixed by consumers.

Postgres
SELECT *
FROM fileattachment
WHERE mimetype IS NULL OR mimetype = ''
  AND length(substring(filename from '\.(?!.*\.).*$')) > 4
ORDER BY filename;
MySQL
SELECT *
FROM fileattachment
WHERE mimetype IS NULL OR mimetype = ''
  AND length(substring_index(filename, '.', -1)) > 4
ORDER BY filename;

 

NOTE: The problem may still occur after updating the fileattachment data until you upgrade to JIRA 6.1 or above or the latest version of the JIRA application Python Library.

Resolution 2

(info) Grant all Operating Systems permissions for the user running JIRA to access the JIRA-home and JIRA-install directories and also full access on the attachments directory.

Last modified on Sep 25, 2019

Was this helpful?

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