Thumbnails do not generate in Confluence
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
Problem
When editing a Confluence page to add an image to it, thumbnails don't generate for certain image attachments (PNG, GIF).
- Edit a Confluence page that has attachments
- Click + > Files and images
- In the Insert files and images dialog, you see spinners instead of thumbnails:
This issue may also manifest in Jira, in which the thumbnails on an issue do not render. See Thumbnails do not generate in Jira running in Azure.
The following may appear in the atlassian-confluence.log
2018-09-13 17:30:41,495 INFO [http-nio-127.0.0.1-8090-exec-32] [pages.thumbnail.renderer.DelegatingThumbnailRenderer] retrieveIfExists More info:
-- referer: http://confluence-base-url/display/OS/Test+Page | url: /download/thumbnails/9193763/image2017-8-29_16-40-12.png | traceId: 2fa2966db05d3258 | userName: user
com.atlassian.confluence.pages.thumbnail.ThumbnailRenderException: java.io.IOException: There is not ImageReader available for the given ImageInputStream
at com.atlassian.confluence.pages.thumbnail.renderer.ThumbnailRenderer.withStreamConsumer(ThumbnailRenderer.java:192)
at com.atlassian.confluence.pages.thumbnail.renderer.ThumbnailRenderer.imageDimensions(ThumbnailRenderer.java:178)
at com.atlassian.confluence.pages.thumbnail.renderer.ThumbnailRenderer.imageDimensions(ThumbnailRenderer.java:171)
at com.atlassian.confluence.pages.thumbnail.renderer.DelegatingThumbnailRenderer.retrieveIfExists(DelegatingThumbnailRenderer.java:83)
at com.atlassian.confluence.pages.thumbnail.renderer.DelegatingThumbnailRenderer.retrieveOrCreateThumbNail(DelegatingThumbnailRenderer.java:118)
at com.atlassian.confluence.pages.thumbnail.DefaultThumbnailManager.lambda$getThumbnail$0(DefaultThumbnailManager.java:161)
at com.atlassian.confluence.impl.util.collections.ConcurrentOperationMap.lambda$computeIfAbsent$0(ConcurrentOperationMap.java:28)
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
at com.atlassian.confluence.impl.util.collections.ConcurrentOperationMap.computeIfAbsent(ConcurrentOperationMap.java:28)
at com.atlassian.confluence.pages.thumbnail.DefaultThumbnailManager.getThumbnail(DefaultThumbnailManager.java:160)
at com.atlassian.confluence.importexport.resource.ThumbnailDownloadResourceManager.getResourceReader(ThumbnailDownloadResourceManager.java:61)
at com.atlassian.confluence.importexport.resource.DelegatorDownloadResourceManager.getResourceReader(DelegatorDownloadResourceManager.java:33)
at com.atlassian.confluence.servlet.download.AttachmentDownload.getStreamForDownload(AttachmentDownload.java:84)
at com.atlassian.confluence.servlet.download.ServeAfterTransactionDownload$StreamResultCallback.doInTransaction(ServeAfterTransactionDownload.java:110)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at com.atlassian.confluence.servlet.download.ServeAfterTransactionDownload.getStreamInTransaction(ServeAfterTransactionDownload.java:36)
at com.atlassian.confluence.servlet.download.ServeAfterTransactionDownload.serveFile(ServeAfterTransactionDownload.java:42)
at com.atlassian.plugin.servlet.AbstractFileServerServlet.doGet(AbstractFileServerServlet.java:28)
...
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: There is not ImageReader available for the given ImageInputStream
at com.atlassian.confluence.content.render.image.ImageRenderUtils.dimensionsForImage(ImageRenderUtils.java:30)
at com.atlassian.confluence.content.render.image.ImageRenderUtils.dimensionsForImage(ImageRenderUtils.java:46)
at com.atlassian.confluence.pages.thumbnail.renderer.ThumbnailRenderer.lambda$imageDimensions$0(ThumbnailRenderer.java:178)
at com.atlassian.confluence.pages.thumbnail.renderer.ThumbnailRenderer.withStreamConsumer(ThumbnailRenderer.java:190)
... 312 more
Diagnosis
Environment
- Instance is hosted in Microsoft Azure (Linux VM, file share)
- Confluence home directory (or shared-home, for Data Center instances) is an Azure file share, mounted to a folder in the VM
Mount options are set with the default user ID and group ID options:
uid=0, noforceuid, gid=0, noforcegid
Diagnostic Steps
- The actual attachments can be viewed and accessed as expected
- The thumbnails folder in the home directory may contain thumbnail files with 0-length
- Files and folders in the home/shared-home directory are owned by root/root
- Check the mount options with sudo mount | grep cifs
Cause
Using the default mount options to lock the gid and uid, thereby resulting in root/root owning all of the files and folders in the mount directory, somehow prevents the thumbnails from being generated.
Resolution
There are two ways to resolve this:
Resolution 1
Re-configure the mount options to set the uid and gid specifically to the user (and the user's group) that runs the application. For example, if you have a dedicated user called confluence and it's in a group called confluence, you will set uid=confluence and gid=confluence in your mount options.
Resolution 2
Add "noperm" to the mount options. An /etc/fstab entry with noperm would look something like this:
//testesourceroupdiag.file.core.windows.net/testazurefs /home/testazure/atlassian/shared-home cifs noperm,nofail,vers=3.0,credentials=/etc/smbcredentials/testesourceroupdiag.cred,file_mode=0777,dir_mode=0777,serverino