Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Confluence Helloworld macro from SDK tutorials is not loading in macro browser

Hi,

I'm trying to follow the Create a Confluence 'Hello World' Macro tutorial but upon reaching the 'Create a Macro Element in Confluence' step, my helloworld macro fails to appear in the macro browser.

confluence-macro-test.gif

From the tutorial, the atlassian-plugin.xml was updated to include xhtml-macro tag:

<xhtml-macro name="helloworld" class="com.atlassian.tutorial.macro.helloworld" key='helloworld-macro'>
<description key="helloworld.macro.desc"/>
<category name="formatting"/>
<parameters/>
</xhtml-macro>

The properties for the plugin were updated:

#put any key/value pairs here
my.plugin.name
=MyPlugin
helloworld.macro.desc="Hello World"

I also added the helloworld.java file in /src/main/java/com/atlassian/tutorial/macro:

package com.atlassian.tutorial.macro;

import com.atlassian.confluence.content.render.xhtml.ConversionContext;
import com.atlassian.confluence.macro.Macro;
import com.atlassian.confluence.macro.MacroExecutionException;

import java.util.Map;

public class helloworld implements Macro {

public String execute(Map<String, String> map, String s, ConversionContext conversionContext) throws MacroExecutionException {
return "<h1>Hello World!</h1><h2>Test</h2>";
}

public BodyType getBodyType() { return BodyType.NONE; }

public OutputType getOutputType() { return OutputType.BLOCK; }

}
 
2017-08-28 11_29_51-helloworld.java — jira-plugins — Visual Studio Code.png
I then ran atlas-mvn package as in the tutorial but that did not allow me to select the helloworld macro from the macro browser. I've also tried ctrl + Z shutting down the sdk application instances and restarting.
 
Is there a step missing from the tutorial?
 
Are there any known issues with the version of the sdk / application I'm running?
 
- confluence version: 5.10.7
- confluence data version: 5.10.5
- amps version: 6.2.11
- ATLAS Version: 6.2.14
- Java version: 1.8.0_121
 
Thanks,
Matt

3 answers

1 accepted

4 votes
Answer accepted

Eventually I tried pulling the source code from bitbucket. I'd made a simple mistake and added the xhtml-macro tag as a child of the  web-resource tag instead of after it:

<web-resource key="myConfluenceMacro-resources" name="myConfluenceMacro Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>

<resource type="download" name="myConfluenceMacro.css" location="/css/myConfluenceMacro.css"/>
<resource type="download" name="myConfluenceMacro.js" location="/js/myConfluenceMacro.js"/>
<resource type="download" name="images/" location="/images"/>

<context>myConfluenceMacro</context>

<xhtml-macro name="helloworld" class="com.atlassian.tutorial.macro.helloworld" key='helloworld-macro' hidden="false">
<description key="helloworld.macro.desc"/>
<category name="formatting"/>
<parameters />
</xhtml-macro>
</web-resource>
 
<web-resource key="myConfluenceMacro-resources" name="myConfluenceMacro Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>

<resource type="download" name="myConfluenceMacro.css" location="/css/myConfluenceMacro.css"/>
<resource type="download" name="myConfluenceMacro.js" location="/js/myConfluenceMacro.js"/>
<resource type="download" name="images/" location="/images"/>

<
context>myConfluenceMacro</context>
</web-resource>

<xhtml-macro name="helloworld" class="com.atlassian.tutorial.macro.helloworld" key='helloworld-macro' hidden="false">
<description key="helloworld.macro.desc"/>
<category name="formatting"/>
<parameters />
</xhtml-macro>

Maybe the instruction "Locate the end of the <web-resource>...</web-resource> section in the file and enter the following:" should be updated to say "Locate the end of the <web-resource>...</web-resource> section in the file and enter the following after the closing web-resource tag"? 

Hopefully this helps others going forward!

great answer, save me time.

rrr, did exactly the same thing ...

Dominic Lagger Community Leader Jan 28, 2020

Thanks a lot! 

It saved me the evaning! I was desperate.! 

@Matt Leary  Matt Leary Thanks a lot !!! :)

Same problem here three years later. Tutorial is very unclear:

"Locate the end of the <web-resource>...</web-resource> section in the file and enter the following:"

How about "Locate the end of the <web-resource>...</web-resource> section in the file and insert the following after:"

or even...

"Locate the </atlassian-plugin> end tag and insert the following just before it:"

it's the bad you haven't change that in the tutorial and all newcomer gat the same f**  problem with in (((

Same problem here.  But also having problems, in general, getting the macro to appear.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

🏑 Atlympic Event: Confluence

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

510 views 18 17
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you