org.springframework.dao.InvalidDataAccessApiUsageException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • This manager provides a service to track {{ImageDetails}} for image attachments. When requesting an {{ImageDetails}} object for an attachment it will create on if it does not exist. The {{ThumbnailManager}} uses this service to provide thumbnails for image attachments. This is the flow: # {{DefaultThumbnailManager.getThumbnailInfo}} is called to get the thumbnail for an attachment # This calls {{DefaultImageDetailsManager.getImageDetails}} to see if there is a stored {{ImageDetails}} object for the attachment # If there is none available {{DefaultImageDetailsManager.createImageDetails}} is called to create one, which is then stored. The problem is {{DefaultImageDetailsManager}} does not define what transactions are required. So if you call this method in a READ_ONLY transaction and there is no {{ImageDetails}} available for the attachment, then you get an exception like this: {noformat} org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER): Turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition. at org.springframework.orm.hibernate.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1000) ... at com.atlassian.confluence.pages.attachments.DefaultImageDetailsDao.save(DefaultImageDetailsDao.java:23) at com.atlassian.confluence.pInvalidDataAccessApiUsageExceptionages.attachments.DefaultImageDetailsManager.storeImageDetails(DefaultImageDetailsManager.java:69) at com.atlassian.confluence.pages.attachments.DefaultImageDetailsManager.createImageDetails(DefaultImageDetailsManager.java:61) at com.atlassian.confluence.pages.attachments.DefaultImageDetailsManager.getImageDetails(DefaultImageDetailsManager.java:49) at com.atlassian.confluence.pages.thumbnail.DefaultThumbnailManager.getThumbnailInfo(DefaultThumbnailManager.java:128) at com.atlassian.confluence.pages.thumbnail.DefaultThumbnailManager.getThumbnailInfo(DefaultThumbnailManager.java:122) {noformat}
    via by Matthew Jensen [Atlassian],
  • This manager provides a service to track {{ImageDetails}} for image attachments. When requesting an {{ImageDetails}} object for an attachment it will create on if it does not exist. The {{ThumbnailManager}} uses this service to provide thumbnails for image attachments. This is the flow: # {{DefaultThumbnailManager.getThumbnailInfo}} is called to get the thumbnail for an attachment # This calls {{DefaultImageDetailsManager.getImageDetails}} to see if there is a stored {{ImageDetails}} object for the attachment # If there is none available {{DefaultImageDetailsManager.createImageDetails}} is called to create one, which is then stored. The problem is {{DefaultImageDetailsManager}} does not define what transactions are required. So if you call this method in a READ_ONLY transaction and there is no {{ImageDetails}} available for the attachment, then you get an exception like this: {noformat} org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER): Turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition. at org.springframework.orm.hibernate.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1000) ... at com.atlassian.confluence.pages.attachments.DefaultImageDetailsDao.save(DefaultImageDetailsDao.java:23) at com.atlassian.confluence.pInvalidDataAccessApiUsageExceptionages.attachments.DefaultImageDetailsManager.storeImageDetails(DefaultImageDetailsManager.java:69) at com.atlassian.confluence.pages.attachments.DefaultImageDetailsManager.createImageDetails(DefaultImageDetailsManager.java:61) at com.atlassian.confluence.pages.attachments.DefaultImageDetailsManager.getImageDetails(DefaultImageDetailsManager.java:49) at com.atlassian.confluence.pages.thumbnail.DefaultThumbnailManager.getThumbnailInfo(DefaultThumbnailManager.java:128) at com.atlassian.confluence.pages.thumbnail.DefaultThumbnailManager.getThumbnailInfo(DefaultThumbnailManager.java:122) {noformat}
    via by Matthew Jensen [Atlassian],
    • org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER): Turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition. at org.springframework.orm.hibernate.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1000) ... at com.atlassian.confluence.pages.attachments.DefaultImageDetailsDao.save(DefaultImageDetailsDao.java:23) at com.atlassian.confluence.pInvalidDataAccessApiUsageExceptionages.attachments.DefaultImageDetailsManager.storeImageDetails(DefaultImageDetailsManager.java:69) at com.atlassian.confluence.pages.attachments.DefaultImageDetailsManager.createImageDetails(DefaultImageDetailsManager.java:61) at com.atlassian.confluence.pages.attachments.DefaultImageDetailsManager.getImageDetails(DefaultImageDetailsManager.java:49) at com.atlassian.confluence.pages.thumbnail.DefaultThumbnailManager.getThumbnailInfo(DefaultThumbnailManager.java:128) at com.atlassian.confluence.pages.thumbnail.DefaultThumbnailManager.getThumbnailInfo(DefaultThumbnailManager.java:122)
    No Bugmate found.