Search code examples
confluenceatlassian-plugin-sdk

Confluence custom macro doesn't show up in Macro Browser


I am following the official tutorial about writing a custom macro for confluence version 5.9.7. The only thing I changed from the tutorial is the plugin name and the package name which you can see in the file I attached here. After running altas-run.bat, I can find in the system configuration page in Confluence that the plugin is successfully installed and enabled, with both the two modules. But when I tried to insert this macro in a page, I couldn't find it in the macro browser.

I then followed another tutorial writing a plugin with JSON in exactly the same step, everything goes fine as the previous one but still can not find the macro in the macro browser. I have spent hours on this issue and got really fed up.

The ExampleMacro.java is under the package com.example.api. Same code as written in the tutorial. Below is the plugin description file. The pom is generated automatically by running atlas-create-confluence-plugin.bat. Nothing changed except for the confluence version to 5.9.7.

<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
    <plugin-info>
        <description>${project.description}</description>
        <version>${project.version}</version>
        <vendor name="${project.organization.name}" url="${project.organization.url}" />
        <param name="plugin-icon">images/pluginIcon.png</param>
        <param name="plugin-logo">images/pluginLogo.png</param>
    </plugin-info>

    <xhtml-macro name="my-confluence-plugin" class="com.example.api.ExampleMacro" key="my-macro">
        <parameters/>
        <category name="navigation" />
    </xhtml-macro>
    <!-- add our i18n resource -->
    <resource type="i18n" name="i18n" location="my-confluence-plugin"/>

    <!-- add our web resources -->
    <web-resource key="my-confluence-plugin-resources" name="my-confluence-plugin Web Resources">
        <dependency>com.atlassian.auiplugin:ajs</dependency>

        <resource type="download" name="my-confluence-plugin.css" location="/css/my-confluence-plugin.css"/>
        <resource type="download" name="my-confluence-plugin.js" location="/js/my-confluence-plugin.js"/>
        <resource type="download" name="images/" location="/images"/>
        <context>my-confluence-plugin</context>
    </web-resource>

</atlassian-plugin>

I found some error message in the atlas-run console after a clean run that I think may provide some information:

[INFO] [talledLocalContainer] 2016-03-31 14:00:29,799 WARN [UpmScheduler:thread-2] [atlassian.upm.pac.PacClientImpl] fetchMpacAppInfo Error when querying application info from MPAC: com.atlassian.marketplace.client.MpacException: java.net.UnknownHostException: marketplace.atlassian.com
[INFO] [talledLocalContainer] 2016-03-31 14:00:32,829 ERROR [AtlassianEvent::CustomizableThreadFactory-1] [atlassian.plugin.module.PrefixDelegatingModuleFactory] createModule Detected an error instantiating the module via Spring. This usually means that you haven't created a <component-import> for the interface you're trying to use. https://developer.atlassian.com/x/TAEr  for more details.
[INFO] [talledLocalContainer] 2016-03-31 14:00:32,830 WARN [AtlassianEvent::CustomizableThreadFactory-1] [impl.macro.metadata.AllMacroMetadataCache] lambda$loadMacroMetadata$1 Failed to make metadata for module 'com.example.my-confluence-plugin:my-macro': Error creating bean with name 'com.example.api.ExampleMacro': Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.confluence.xhtml.api.XhtmlContent]: : No qualifying bean of type [com.atlassian.confluence.xhtml.api.XhtmlContent] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.confluence.xhtml.api.XhtmlContent] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
[INFO] [talledLocalContainer] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.example.api.ExampleMacro': Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.confluence.xhtml.api.XhtmlContent]: : No qualifying bean of type [com.atlassian.confluence.xhtml.api.XhtmlContent] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.confluence.xhtml.api.XhtmlContent] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

Why does it complains that no qualifying bean of type XhtmlContent is found?


Solution

  • I am using Atlassian SDK v6.2.4.

    Just figured out the problem. Seems like this is a common issue that many people met. For the one who is also using the latest SDK and following the current tutorial by Confluence, please see my answer in the forum of Atlassian here : https://answers.atlassian.com/questions/38064029/answers/38064450