Unable to load macro browser due to ClassCastException
Symptoms
When trying to add a macro in Confluence Editor, instead of showing a macro browser, a pop up box appears:
There has been an error loading the macro browser. Please try again or see your system administrator.
The following appears in the atlassian-confluence.log
:
2012-08-10 15:03:21,194 ERROR [http-8080-7] [atlassian.confluence.servlet.ConfluenceServletDispatcher] sendError Could not execute action
-- url: /confluence/plugins/macrobrowser/browse-macros.action | userName: eprout | referer: http:/<confluence-url>/pages/editpage.action?pageId=<pageID>
java.lang.ClassCastException: java.lang.String cannot be cast to com.atlassian.confluence.renderer.UserMacroConfig
at com.atlassian.confluence.macro.browser.UserMacroMetadataProvider.extractMetadata(UserMacroMetadataProvider.java:27)
at com.atlassian.confluence.macro.browser.UserMacroMetadataProvider.getData(UserMacroMetadataProvider.java:20)
at com.atlassian.confluence.macro.browser.DefaultMacroBrowserManager.buildMacroMetadata(DefaultMacroBrowserManager.java:59)
at com.atlassian.confluence.macro.browser.DefaultMacroBrowserManager.getMacroMetadata(DefaultMacroBrowserManager.java:49)
at com.atlassian.confluence.macro.browser.actions.BrowseMacrosAction.execute(BrowseMacrosAction.java:22)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:168)
at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
.....
The error above is thrown when Confluence is trying to access the following URL in order to load the macro browser:
http://<confluence-url>/plugins/macrobrowser/browse-macros.action
The following appears in the browser JS console:
Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://<confluence-url>/plugins/macrobrowser/browse-macros.action
Cause
There are some data with incorrect format (i.e. string) saved into User Macro field in the BANDANA table. To verify, try to execute the following SQL query:
SELECT * FROM BANDANA WHERE BANDANAKEY='atlassian.confluence.user.macros'
The BANDANAVALUE row needs to have an XML format (i.e. <map/> for empty user macros or <map>.....</map> for one or more user macros). If the value is of <string>...</string> format, please refer to the resolution to fix it.
Resolution
- Backup your Confluence database
Run the following SQL query to remove all of the created user macros
UPDATE BANDANA SET BANDANAVALUE='<map/>' WHERE BANDANAKEY='atlassian.confluence.user.macros';
- Restart Confluence