Unable to Upload an attachment due to 'RuntimeException Multiple AttachmentData objects were returned when only one was expected'

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

ℹ️ The SQL queries in this documentation are tailored for Confluence 5.6 and below only.

Problem

Confluence cannot upload a specific attachment. The following appears in the atlassian-confluence.log:

1 2 3 4 5 6 7 8 9 java.lang.RuntimeException: Multiple AttachmentData objects were returned when only one was expected at com.atlassian.confluence.pages.persistence.dao.hibernate.HibernateAttachmentDataDao.getAttachmentDataForAttachment(HibernateAttachmentDataDao.java:67) at com.atlassian.confluence.pages.persistence.dao.hibernate.HibernateAttachmentDataDao.saveDataForAttachmentVersion(HibernateAttachmentDataDao.java:137) at com.atlassian.confluence.pages.persistence.dao.hibernate.AbstractHibernateAttachmentDao.saveNewAttachmentVersion(AbstractHibernateAttachmentDao.java:204) at com.atlassian.confluence.pages.DefaultAttachmentManager.saveNewAttachmentVersion(DefaultAttachmentManager.java:55) at com.atlassian.confluence.pages.AbstractAttachmentManager.saveAttachment(AbstractAttachmentManager.java:89) at com.atlassian.confluence.pages.DelegatorAttachmentManager.saveAttachment(DelegatorAttachmentManager.java:87) at sun.reflect.GeneratedMethodAccessor1707.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

Cause

As the error message indicates, there was more than one object returned when only one was expected.

Resolution

  1. Rename the attachment and upload again.

  2. If the problem persists or affects a different usage pattern, please use the following steps:

    1. Identify duplicates from attachmentdata table in the database

      1 select attachmentdataid, attachmentid, attversion, count(*) from ATTACHMENTDATA group by attachmentid, attachmentdataid, attversion having count(*)>1;
    2. Delete the duplicates that have the same attachmentid and attversion, leaving the version which has the greatest attachmentdataid:

      1 delete from ATTACHMENTDATA where attachmentdataid=<put in attachmentdataids here>;
    3. Last step is to How to Rebuild the Content Indexes From Scratch on Unclustered Confluence

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.