Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Matt Leary
Contributor
August 28, 2017

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

5 votes
Answer accepted
Matt Leary
Contributor
August 28, 2017

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!

Ocean MIH
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 14, 2019

great answer, save me time.

belteshazzar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 26, 2020

rrr, did exactly the same thing ...

Dominic Lagger
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 28, 2020

Thanks a lot! 

It saved me the evaning! I was desperate.! 

harshahid_h February 27, 2020

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

Matt Flaherty
Contributor
September 18, 2020

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:"

Like Kixar likes this
0 votes
Brock Price
Contributor
February 9, 2021

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

0 votes
serge alex
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 3, 2019

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events