User Macro's from Confluence Server not working in Confluence Datacenter
Asked by Keimpe de Jong:

Hello,

I'm currently using a Confluence Data Center trial license and discovered the following:

The user macro's made under Confluence Server aren't working in Confluence Data Center 7.19.7.

Can't figure it out;  
any ideas how to solve this?


Answers:
author: Keimpe de Jong
body: This is most likely the bug causing the user macro issues: <https://jira.atlassian.com/browse/CONFSERVER-82741>


author: Craig Nodwell
body: Hi [@Keimpe de Jong](/t5/user/viewprofilepage/user-id/67254) is there anything in the user macros that points to the old server? Re icon URL ?  

comments: author: Keimpe de Jong
body: Hello [@Craig Nodwell](/t5/user/viewprofilepage/user-id/3973516) no reference to any server. I'll share the user macro(s) in a reply.


author: Radek Dost?l
body: Server and DC share the same code base. Whatever the problem is, it's not because of data center. As far as problem reports go, this is extremely poor because you provided no code, no errors, no context, so all we can do is guess.

comments: author: Keimpe de Jong
body: The aim of my question is to get in touch with other community members who have experience with failing user macro's moving from Server to Data Center.  
That's why I didn't provide the failing user macro.

Thanks for your answer.


author: Ally Lancaster
body: Hi [@Radek Dost?l](/t5/user/viewprofilepage/user-id/715713) - I have the same issue for a user macro designed to show date last modified. It is no longer working. Any suggestions?

```
## @noparamsLast Modified: $action.dateFormatter.formatDateTime($content.lastModificationDate)?
```


author: Keimpe de Jong
body: This User Macro is used to create a custom page listing a specific set of global active spaces.  
In the near future a filter on the space category has to be added.

Example of a failing User Macro in Confluence Data Center:  

## @noparams  
#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($spaces = $spaceManager.getAllSpaces())

#foreach($space in $spaces)

##uitsluiten personal en archived spaces  
#if( $space.isPersonal() or $space.isArchived() )  
#else

\<tr\>  
\<ul\>  
\<td\>\<li\>\<a id="spacelink-spacekey" href="/display/$space.Key" target="_top"\>$space.Name\</a\>\</li\>\</td\>  
\</ul\>  
\</tr\>  
#end  
#end

Any ideas?


author: Bill Bailey
body: Were your macros written for an older version of Confluence? I had a number of user macros that when moving from server 6.13 to 7.4, did not work fully. It was because some of the classes had been deprecated.

I also noticed that for inexplicable reasons, Atlassian restricted some access for user macros (restricted some methods from the Velocity context). So for example setting content properties was restricted.

Do you know what is failing in your macros? Have you checked the logs to see if there is a clue in there?

comments: author: Keimpe de Jong
body: I don't know what too look for and in which log due to lack of experience with failing user macro's.

Can you point the way?


author: Bill Bailey
body: From the admin console, you can download the logs. The best steps to find an issue is:

1. Refresh the page with the failing macro. Note the page ID
2. Generate and download the latest logs.
3. Search for the page ID (or failing that, work backwards looking at time stamps).
4. You should see some warning, error messages that may point to specific classes by unknown/unrecognized.

What was the server version where the macro was working?


author: Keimpe de Jong
body: Server version was 7.19.3

From the logs:

2023-04-19 17:18:33,431 ERROR \[http-nio-8090-exec-3\] \[renderer.internal.http.HttpClientFetcher\] fetch Unable to perform a request to: <https://confluence> base url/ rest/gadgets/1.0/g/messagebundle/und/gadget.common%2Cgadget.activity.stream  
-- referer: <https://confluence> base url/ display/Space key/Page name \| url: /plugins/macrobrowser/browse-macros.action \| traceId: eca4029d328f4ef0 \| userName: \*\*\*\* \| action: browse-macros  
org.apache.http.conn.ConnectTimeoutException: Connect to confluence base url:443 \[confluence base url/IP adress\] failed: connect timed out


author: Bill Bailey
body: Looks like there was some configuration change that blocking the requests. Did the URL change, or is rest socket not enabled? Or is the user credentials the macro using active?


Tags: confluence-server

data-center

server

user-macro