"Error occurred rendering template content" with User Macros

Hi all,

Before upgrading to Confluence v 5.10.5, my two custom User Macros worked fine. Here is the code of one of them:

 

## Macro name: number-of-comments
## Visibility: Visible only to system administrators in the Macro Browser
## Macro title: Number of comments
## Description: Returns the number of comments for a given page
## Categories: Confluence content, Reporting
## Macro body processing: No macro body
##
## Developed by: Nicolas Casel
## Date created: 03.07.2016
## Installed by: Nicolas Casel
## @param PageID:title=Page ID|type=int|required=false|desc=ID of page to count comments
##
## Check for page id parameter, otherwise use default of current page
#if (!$paramPageID)
#set ($paramPageID=$content.id)
#end
##
#set( $containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager') )
#set( $getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null) )
#set( $containerManager=$getInstanceMethod.invoke(null,null) )
#set( $containerContext=$containerManager.containerContext )
#set( $pageManager=$containerContext.getComponent('pageManager') )
#set( $commentManager=$containerContext.getComponent('commentManager') )
##
#set ($targetPage = $action.page)
## Set up integer object to handle string conversion of page id
#set($Integer = 0)
##
#if ($pageManager)
#set ($targetPage = $pageManager.getPage($Integer.parseInt($paramPageID)))
#end
##
#set($count = $commentManager.countComments($targetPage))
#if ($commentManager)
##<span class="commentcount">$count</span>
<aui-badge style="background-color: #d04437; color: white;">$count</aui-badge>
#end
#end

 

Since Confluence v 5.10.5, I get this message:

Error rendering macro 'number-of-comments' : Error occurred rendering template content

 

Any idea of the reason? Thank you!

 

1 answer

1 vote
Stephen Deutsch Community Champion Oct 27, 2016

The easiest way to see what is wrong is to look in the log file <confluence_home_directory>/logs/atlassian-confluence.log. Whenever it shows an "Error occurred rendering template content", there will be an accompanying entry in the log file with more details.

One thing you might try is to change 

#set ($targetPage = $action.page)

to

#set ($targetPage = $content)

The easiest way to see what is wrong is to look in the log file <confluence_home_directory>/logs/atlassian-confluence.log

Thanks for this insight.

In this case, I found the solution: removing the last:

#end

(last line)

 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Published 12 hours ago in Confluence

Think you know shares vs. @mentions in Confluence? Take this collab quiz.

To anyone who doubts that Atlassians are a little too obsessed with collaboration, and tools related thereto, let me describe a recent discussion we had (which took place on our internal Confluence, ...

96 views 2 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you