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

Still need help?

The Atlassian Community is here for you.

Ask the community

(info) 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:

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

      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:

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

Last modified on Mar 30, 2016

Was this helpful?

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