Atlassian SDK Example - Create a Confluence Macro doesn't show up in Macro Browser

I followed instructions to create a Confluence macro, after completing the exercise to create a Jira plugin.

This doesn’t show the macro from the macro browser, like the instructions say. Instead, I find the macro listed under ‘Manage Add-ons’…as if it were a plugin. I’ve been told that may be okay, as a macro is a subset of a plugin. But I’m tired of being told to wait a few seconds or minutes before the macro will appear in the macro browser. I’ve waited for several days now, and it doesn’t appear in the macro browser.

I checked my code against the code in bitbucket and my code looks fine.

I’d like to get the macro to appear in the list of macros, so I can use it.

I am seeing exceptions in the console about not finding the properties file, not sure why. I created the file it complains about, is this why the macro isn’t being listed in the browser? or is this a red herring?

[INFO] [talledLocalContainer] java.lang.RuntimeException: Cannot getResourceAsStream(myConfluenceMacro_en_US.properties): This operation must occur before the plugin ‘com.atlassian.tutorial.myConfluenceMacro’ is uninstalled. Listener: com.atlassian.confluence.impl.audit.listener.PluginAuditListener event: com.atlassian.confluence.event.events.plugin.AsyncPluginInstallEvent

Hi @splinterface,

Good call on creating the myConfluenceMacro_en_US.properties. That should pacify the logs . I have my own confluence macro sample app and tested it recently and I was able to see the macro in the macro browser as well as the Manage Add-ons page but you have to wait for some time. As per our doco:

Note: It can take the Confluence macro browser a little bit of time to realise that there’s a new macro available, so if it doesn’t show up right away give it a little while and try again.

Now, to be on the same page as you:

  1. I cloned the macro from the Bitbucket repository (which should have the same code as yours) and ran atlas-run.
  2. I was not able to see the plugin first in the Manage Add-ons, so I ran atlas-mvn package on another terminal to see what the problems is. And I had the similar error as you - I’m missing an i18n properties file. Which I’m not sure why it was throwing that. If you’re not yet familiar with atlas-mvn package, it’s the command to build a new jar file and install it in the running Confluence server or in short quick reloading.
  3. So, I created the file, for me it was : myConfluenceMacro_en_GB.properties, and ran atlas-mvn package. Got no errors. So far, so good.
  4. Refreshed: http://localhost:1990/confluence/plugins/servlet/upm to see if my myconfluencemacro is installed, and it is. Awesome.
  5. Now, create a new page to test your new macro. In the page editor, type { to search or click on the + to open the macro browser. Search for Helloworld since that is the name of our macro, for reference:
<xhtml-macro name="helloworld" class="com.atlassian.tutorial.macro.helloworld" key='helloworld-macro'>
        <description key="helloworld.macro.desc"/>
        <parameters>
            <parameter name="Name" type="string" />
            <parameter name="Color" type="enum">
                <value name="red"/>
                <value name="green"/>
                <value name="blue"/>
            </parameter>
        </parameters>
    </xhtml-macro>

  1. I put some values in the parameters, as such:

Let me know if you have anymore questions or clarifications.

Cheers,
Anne Calantog

Hi Anne,

Thank you very much for your time on this matter and for your response.

I also had the issue with the _en_GB file but I changed my locale on my instance to be English US rather than English UK. Still, even after running ‘atlas-mvn package’, and having Quick Reload enabled, I still get the exception:
[INFO] [talledLocalContainer] java.lang.RuntimeException: Cannot getResourceAsStream(myConfluenceMacro_en_US.properties): This operation must occur before the plugin ‘com.atlassian.tutorial.myConfluenceMacro’ is uninstalled.

Granted, I didn’t clone the Bitbucket repo, I wrote the code by following the example here.

I only went as far as step 11 in ‘Create a Macro Element in Confluence’ since I can’t get the macro to load.

I’ve respected the arbitrary wait time for Confluence to realise there is a new macro. I figured two days was enough wait time :slight_smile: I suspect the exception by not finding the i18n file is causing it not to load or be recognized by the macro browser.

I cannot get past step 5 in your post, but I do still see the macro listed under add-ons.

One thing I can do is start over and clone the repo, and start with the answer. However, if I follow instructions and have this error, I’d rather try to understand why this is happening and fix it, so I can continue following instructions verbatim.

I have the i18n file properly created:
image

And I looked in the .jar and I see both i18n files are there also. Is there a specific path in which these should be placed? currently they are in the root of the .jar.

My next action will be to clone the repo and start there, like you did, and see if it works. But if it works, I’ll never know what the issue was :slight_smile:

and sorry, for some reason, I’m not “allowed” to put more than one image on a post, otherwise I’d offer more graphical input.

Hi Anne,

I was able to get things working fine after pulling down the entire source. This takes me a step forward in where I was in the tutorial. This is great!

I was also able to do a more indepth code comparison with my hand-edited code vs the repo. This appears to be why my macro was not found in the macro browser. See the issue?

Also, when I run atlas-run from my code, I get Confluence v6.7.1 – and I still get the getResourceAsStream() error. The pom.xml shows 6.7.1. However, when I run from the code in the repo, I get Confuence 5.10.7. Not sure if the version is somehow related to the getResourceAsStream.

Nevertheless, I figured out why mine didn’t work in the first place (atlassian-plugin.xml wasn’t quite right), and got it to work as well as getting the final code to work.

Thanks for your help on this issue!

1 Like

Hi @splinterface,

That’s awesome! Glad you were able to make it work! Happy coding.

Cheers,
Anne Calantog

I made the exact mistake that splinterface did (pasted the xhtml-macro element inside the end of the existing web-resource element instead of AFTER the end tag for the web-resource element).

The instructions can be interpreted that way:
"Locate the end of the <web-resource>...</web-resource> section in the file and enter the following:" (with a snippet of xhtml-macro XML).

https://developer.atlassian.com/server/framework/atlassian-sdk/create-a-confluence-hello-world-macro/

It would be really nice to have some schema to validate our XML against. I can’t find DTD or XSD for atlassian-plugin.xml anywhere. I can’t tell if this Jira issue was resolved by providing us some schema: Provide atlassian-plugin.xml DTD or XSD

In this case XML schema would have been nice to have because the invalid markup parsed OK and the plugin installed OK but it did not show up in the macro browser. It was difficult to troubleshoot until I found this thread.

Thanks!

1 Like