'Unable to Locate JIRA Server For This Macro' displayed after changing JIRA Application Link name
Problem
When trying to view a page with a JIRA Issues macro, instead of JIRA content, the following message appears:
Error rendering macro 'jira' : Unable to locate JIRA server for this macro. It may be due to Application Link configuration.
Cause
After changing the JIRA Application Link name, Confluence did not update the page content to reflect the new name, breaking the links and generating the above message.
On later versions of Confluence, this could be due to the change in JIRA's serverID, example:
<ac:parameter ac:name="serverId">0df2b677-789b-32fa-a28e-b970cc2ea317</ac:parameter>
To confirm this is the case in your instance, run the following SQL query:
select count(body) from bodycontent where body like '%<ac:parameter ac:name="server">OLD_LINK_NAME</ac:parameter>%' and body is not null ;
The above query will search in all pages of the system for the old link and inform how many entries are in there. If the result is bigger than 0 please proceed with the resolution steps below.
Resolution
- Backup your Confluence database
- Shutdown Confluence
Run the following SQL statement, which will replace all existing references to the JIRA Application link with the new name. Ensure you replace OLD_LINK_NAME and NEW_LINK_NAME with the appropriate values, if you are having difficulty identifying those values there are information in the last segment of this document
UPDATE bodycontent SET body = Replace(body, '<ac:parameter ac:name="server">OLD_LINK_NAME</ac:parameter>', '<ac:parameter ac:name="server">NEW_LINK_NAME</ac:parameter>') WHERE body LIKE '%<ac:parameter ac:name="server">OLD_LINK_NAME</ac:parameter>%';
For some databases, such as MSSQL, you may need to use a CAST to replace ntext:
UPDATE BODYCONTENT SET BODY = CAST(REPLACE(CAST(BODY as NVarchar(MAX)), '<ac:parameter ac:name="server">OLD_LINK_NAME</ac:parameter>', '<ac:parameter ac:name="server">NEW_LINK_NAME</ac:parameter>') as NText) WHERE BODY LIKE '%<ac:parameter ac:name="server">OLD_LINK_NAME</ac:parameter>%';
- Restart Confluence
- Rename the Application link to the new name.
In case the above does not resolve the issue:
- Insert a new JIRA macro to the affected page
- Make sure that the new macro works (if that's the case, then this KB is applicable)
Look for the new macro's serverID and compare it to the old one (via the page's Storage Format). Example:
New Macro:<ac:parameter ac:name="serverId">d8d416ca-1f70-3b24-8a64-16cc111e7b15</ac:parameter>
Old Macro:<ac:parameter ac:name="serverId">0df2b677-789b-32fa-a28e-b970cc2ea317</ac:parameter>
Take note of the new and old serverIDs, then take a backup of the Confluence DB, before running this:
UPDATE bodycontent SET body = Replace(body, '<ac:parameter ac:name="serverId">OLD_ID</ac:parameter>', '<ac:parameter ac:name="serverId">NEW_ID</ac:parameter>') WHERE body LIKE '%<ac:parameter ac:name="serverId">OLD_ID</ac:parameter>%';
Example:
UPDATE bodycontent SET body = Replace(body, '<ac:parameter ac:name="serverId">0df2b677-789b-32fa-a28e-b970cc2ea317</ac:parameter>', '<ac:parameter ac:name="serverId">d8d416ca-1f70-3b24-8a64-16cc111e7b15</ac:parameter>') WHERE body LIKE '%<ac:parameter ac:name="serverId">0df2b677-789b-32fa-a28e-b970cc2ea317</ac:parameter>%';