System error while loading pages with attachments in Confluence 5.4.x or earlier versions

Still need help?

The Atlassian Community is here for you.

Ask the community

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


Summary

Navigating to a page that has attachments triggers a "System Error" in the UI: 

The following error appears on the page:

Click here to expand...
Cause
java.lang.RuntimeException: Error rendering template for decorator root
    at com.atlassian.confluence.setup.velocity.ApplyDecoratorDirective.render(ApplyDecoratorDirective.java:191)
caused by: java.lang.RuntimeException: Error rendering template for decorator page
    at com.atlassian.confluence.setup.velocity.ApplyDecoratorDirective.render(ApplyDecoratorDirective.java:191)
caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getDisplayableLabel' in class com.atlassian.confluence.plugin.descriptor.web.model.ConfluenceWebLabel threw exception com.atlassian.core.exception.InfrastructureException: Error occurred rendering template content at template/includes/menu-macros.vm[line 281, column 36]
    at org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:337)
caused by: com.atlassian.core.exception.InfrastructureException: Error occurred rendering template content
    at com.atlassian.confluence.util.velocity.VelocityUtils.writeRenderedContent(VelocityUtils.java:187)
caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getLatestVersionsOfAttachments' in class com.atlassian.confluence.pages.Page$$EnhancerByCGLIB$$b6314f3d threw exception net.sf.hibernate.LazyInitializationException: cannot access loading collection at getRenderedContent[line 1, column 15]
    at org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:337)
caused by: net.sf.hibernate.LazyInitializationException: cannot access loading collection
    at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:191)
Stack Trace:[hide]
java.lang.RuntimeException: Error rendering template for decorator root
	at com.atlassian.confluence.setup.velocity.ApplyDecoratorDirective.render(ApplyDecoratorDirective.java:191)
	at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175)
....
Caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getLatestVersionsOfAttachments' in  class com.atlassian.confluence.pages.Page$$EnhancerByCGLIB$$b6314f3d threw exception net.sf.hibernate.LazyInitializationException: cannot access loading collection at getRenderedContent[line 1, column 15]
	at org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:337)
	at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:284)
	at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:262)
	at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:342)
	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
	at org.apache.velocity.runtime.RuntimeInstance.render(RuntimeInstance.java:1277)
	at org.apache.velocity.runtime.RuntimeInstance.evaluate(RuntimeInstance.java:1216)
	at org.apache.velocity.runtime.RuntimeInstance.evaluate(RuntimeInstance.java:1165)
	at org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngine.java:219)
	at com.atlassian.confluence.util.velocity.VelocityUtils.writeRenderedContent(VelocityUtils.java:179)
	... 483 more
Caused by: net.sf.hibernate.LazyInitializationException: cannot access loading collection
	at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:191)
	at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)
	at net.sf.hibernate.collection.Bag.iterator(Bag.java:256)
	at com.atlassian.confluence.core.ContentEntityObject.getLatestVersionsOfAttachments(ContentEntityObject.java:614)
	at com.atlassian.confluence.core.ContentEntityObject$$FastClassByCGLIB$$96df24d5.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
	at net.sf.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:108)
	at com.atlassian.confluence.pages.Page$$EnhancerByCGLIB$$b6314f3d.getLatestVersionsOfAttachments(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:389)
	at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:378)
	at com.atlassian.confluence.velocity.introspection.UnboxingMethod.invoke(UnboxingMethod.java:34)
	at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270)
	... 491 more

Environment

Confluence server and Datacenter 5.4.x or earlier versions

Diagnosis

Search the <confluence-home>/logs/atlassian-confluence.log file for the error message in the UI. In the stack trace, we may find the following Caused By:


Caused by: net.sf.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.atlassian.confluence.pages.Attachment.minorEdit
	at net.sf.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:57)
	at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:229)
	at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2239)
	at net.sf.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:319)
	at net.sf.hibernate.loader.Loader.doQuery(Loader.java:309)
	at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
	at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:1020)
	at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:995)
	at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:93)
	at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:288)
	at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3330)
	at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:195) 


If we find the aforementioned error, run the following query, if it returns any records, you're affected by the issue reported in this KB:

SELECT * FROM ATTACHMENTS WHERE MINOR_EDIT IS NULL;

(info) This KB doesn't apply to Confluence 5.5.x or later versions – Confluence 5.4.x or earlier versions had the option to store attachments in the database, this was configurable during Confluence installation. The Attachments table was created for this and was deprecated in Confluence 5.5.x. We no longer offer the option to store the attachments in the database in this version and newer. 

(warning) Exception: If the attachments table still exists in Confluence 5.5.x or later versions, the recommended attachment migration from the database to the file system wasn't executed so we need to perform the migration.

Cause

The root cause is unknown, however, there's a problem with attachment metadata and what Confluence expects. Specifically, there are records in the attachments table that has a NULL value in the MINOR_EDIT column. Even though NULL values are allowed, Confluence doesn't expect to find them and throws an error. 

Resolution

  1. Backup your database
  2. Modify the records in the attachments table that returns a NULL:

    UPDATE ATTACHMENTS
    SET MINOR_EDIT = ''
    WHERE MINOR_EDIT IS NULL;
  3. Flush the Confluence caches at Cache Management > Click on Show advanced view > Scroll all the way down and click on Flush all
  4. Rebuild the index through the UI, at the Content Indexing page
  5. Navigate to the problematic page(s) 


Last modified on Nov 12, 2020

Was this helpful?

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