I'm running through the (old) Confluence Macro Tutorial from Atlassian. Rather than download the 500+ MB of source (the /target dir is in the initial checkin!), I created a new plugin and pasted in the Example Macro source, and config info.
Server runs, but on bringing up the macro browser, an error is thrown it the console.
[INFO] [talledLocalContainer] 2015-11-04 23:17:33,530 ERROR [http-nio-1990-exec-10] [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] -- referer: http://127.0.0.1:1990/confluence/pages/editpage.action?pageId=98310 | url: /confluence/plugins/macrobrowser/browse-macros.action | userName: admin | action: browse-macros [INFO] [talledLocalContainer] 2015-11-04 23:17:33,560 WARN [http-nio-1990-exec-10] [impl.macro.metadata.AllMacroMetadataCache] lambda$loadMacroMetadata$165 Failed to make metadata for module 'com.cisco.macrotest:my-macro': Error creating bean with name 'com.cisco.ExampleMacro': Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.confluence.xhtml.api.XhtmlContent]: : No unique bean of type [com.atlassian.confluence.xhtml.api.XhtmlContent] is defined: Unsatisfied dependency of type [interface com.atlassian.confluence.xhtml.api.XhtmlContent]: expected at least 1 matching bean; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.atlassian.confluence.xhtml.api.XhtmlContent] is defined: Unsatisfied dependency of type [interface com.atlassian.confluence.xhtml.api.XhtmlContent]: expected at least 1 matching bean
I'm using Atlas plugin 6.1.0 and it's generating a maven pom.xml with Confluence 5.8.15:
<confluence.version>5.8.15</confluence.version> <confluence.data.version>5.8.8</confluence.data.version> <amps.version>6.1.2</amps.version> <plugin.testrunner.version>1.2.3</plugin.testrunner.version> <atlassian.spring.scanner.version>1.2.6</atlassian.spring.scanner.version>
For grins, I even added a component-import config to the atlassian-plugin.xml, but no luck.
<component-import key="xhtmlContent" interface="com.atlassian.confluence.xhtml.api.XhtmlContent"/>"
Community moderators have prevented the ability to post new answers.
Learned more... seems like the "instructions" block provides info about how to process the dependencies into OSGI Bundles. Problem there was that it seems to have prevented correct packaging of the Atlassian libs.
Removing this section made the UserAccessor injectable.
<instructions> <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key> <!-- Add package to export here --> <Export-Package> com.yourcompany.api, </Export-Package> <!-- Add package import here --> <Import-Package> org.springframework.osgi.*;resolution:="optional", org.eclipse.gemini.blueprint.*;resolution:="optional", * </Import-Package> <!-- Ensure plugin is spring powered - see https://extranet.atlassian.com/x/xBS9hQ --> <Spring-Context>*</Spring-Context> </instructions>
Thank u one more time!
You saved so much time for me spended for fighting with super-fast-new-way-to-package
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does Atlassian ever actually QA the basic macro/plugin dev tutorials anymore? The macro page says this was last updated in 2013 and tested with 5.2!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, Steve. I converted it into an answer so others will see it, but will ask the developer (Anurag) who found it to post it as The Answer so I don't take credit for something he figured out.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tim Colson (Cisco) Thanks for this ^ last post. This is exactly what the problem was. Interestingly enough its added automatically in the pom by atlas-create-confluence-rest-module! Go figure. The "resolution:=optional" is particularly insidious as it a) not recommended to use and b) hides version conflict errors at startup in favor of much more bewildering UnsatisfiedDependencyExceptions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Some good news... I've learned that unless you need to process the page body, you don't need the XhtmlContent object, so just ditch it. That said, I do need the UserAccessor, and it throws the same error. Well, it did b/c I had the "wrong one". Then I picked the correct package, and it seemed to work for about 4 hours, and then it stopped working. Seriously. As a workaround, I'm grabbing that devil from the Velocity Context (yes, egregious hack, but it works all the time, dammit) -> UserAccessor userAccessor = (UserAccessor) context.get("userAccessor");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found that sometimes importing components this way fails, but works when defining the interface as child element rather than attribute.
For example I couldn't get the SAL Transaction Template to work this way, but when using
<component-import name="SAL Transaction Template" key="transactionTemplate"> <interface>com.atlassian.sal.api.transaction.TransactionTemplate</interface> </component-import>
Spring injection works like a charm. Maybe that'll help in your case, too?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the idea, Patrick. I just gave this a try, still fails with the same error: <component-import name="User Accessor" key="userAccessor"> <interface>com.atlassian.confluence.user.UserAccessor</interface> </component-import>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just to make sure: is the component import showing up in your plugin modules? You would find these on the addon administration screen. Still, UserAccessor should not need a component import in first place. Have you tried both injection via setter and constructor?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did try both, even though I believe setter injection is not recommended for Plugins2. Constructor fails with no beans available, and setter fails later with an NPE.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'd sure love to know how to solve this. It seems dependency injection simply doesn't work at all for UserAccessor. Confluence 5.9. SDK 6.2.2. Have some functionality dead-in-the-water. Every single time it generates a NoSuchBeanDefinition exception.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.