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) ...

Atlassian JIRA | Matthew Jensen [Atlassian] | 3 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    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}

    Atlassian JIRA | 3 years ago | 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) ...
  2. 0

    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}

    Atlassian JIRA | 3 years ago | 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) ...

    Root Cause Analysis

    1. 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()
    2. com.atlassian.confluence
      DefaultThumbnailManager.getThumbnailInfo
      1. com.atlassian.confluence.pages.attachments.DefaultImageDetailsDao.save(DefaultImageDetailsDao.java:23)
      2. com.atlassian.confluence.pInvalidDataAccessApiUsageExceptionages.attachments.DefaultImageDetailsManager.storeImageDetails(DefaultImageDetailsManager.java:69)
      3. com.atlassian.confluence.pages.attachments.DefaultImageDetailsManager.createImageDetails(DefaultImageDetailsManager.java:61)
      4. com.atlassian.confluence.pages.attachments.DefaultImageDetailsManager.getImageDetails(DefaultImageDetailsManager.java:49)
      5. com.atlassian.confluence.pages.thumbnail.DefaultThumbnailManager.getThumbnailInfo(DefaultThumbnailManager.java:128)
      6. com.atlassian.confluence.pages.thumbnail.DefaultThumbnailManager.getThumbnailInfo(DefaultThumbnailManager.java:122)
      6 frames