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

atlassian-plugin.xml contains a definition of component-import. This is not allowed when Atlassian-Plugin-Key is set

Amolak Nagi March 24, 2016

Hi!

I was following the tutorial here:

https://developer.atlassian.com/docs/getting-started/learn-the-development-platform-by-example/control-access-with-sal

And in the tutorial I added the 4 SAL modules in Step 1. And as the tutorial shows, 4 component-imports show up in the atlassian-plugin.xml file. However, when I try to run it as the tutorial says, I get this error:

atlassian-plugin.xml contains a definition of component-import. This is not allowed when Atlassian-Plugin-Key is set

Based on this error, I tried going to pom.xml and commenting out the line that defines Atlassian-Plugin-Key. Doing so allowed atlas-run to complete successfully, but then when I go to the servlet link it appears blank and nothing shows up no matter what I try.

Any assistance would be great.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

10 votes
Answer accepted
Jon Mort [Adaptavist]
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.
March 24, 2016

The tutorial is out of date. Newer versions of the SDK use Atlassian Spring Scanner instead of <component> and <component-import>.

You have 2 options:

  1. Use the Spring Scanner Annotations (recommended)
  2. Use an older version of the SDK to generate the plugin skeleton, any 5.x version will do

 

Amolak Nagi March 25, 2016

I think I understand it a little bit. I see how they write the code for Spring Scanner Annotations, but I'm really new to this. Which code file to I add the annotations to?

Amolak Nagi March 25, 2016

Sorry I'm really confused. I assume I need to import the java files into my main servlet file. But I don't know how to write the code for simple plugins in the tutorial.

 

For instance, I have these 4 components:

<component-import key="templateRenderer" interface="com.atlassian.templaterenderer.TemplateRenderer" filter=""/>
<component-import key="userManager" interface="com.atlassian.sal.api.user.UserManager" filter=""/>
<component-import key="loginUriProvider" interface="com.atlassian.sal.api.auth.LoginUriProvider" filter=""/>
<component-import key="pluginSettingsFactory" interface="com.atlassian.sal.api.pluginsettings.PluginSettingsFactory" filter=""/>

 

They're the simple components used in the tutorial, but I have no idea how to set this up using the Spring Scanners.

Jeremy Jao May 12, 2016

err.... atlas-create-jira-plugin-module -> 1: Component Import still does the old outdated way...

Like hezheng likes this
koenemann May 24, 2016

Could you please provide more information how to "Use the Spring Scanner Annotations (recommended)"?

Or maybe you could point to some page that explains how to do that for TemplateRenderer and UserManager?

Jon Mort [Adaptavist]
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.
May 24, 2016

This answer might help.

koenemann May 24, 2016

Thank you, that was helpful! One more note: for getting the current user, I use this:

private ApplicationUser getCurrentUser(HttpServletRequest req) {
  return ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
}
Jon Mort [Adaptavist]
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.
May 25, 2016

You shouldn't really mix injection and use of ComponentAccessor they do the same thing. You should be able to inject the JiraAuthenticationContext in the same way you inject UserManager

koenemann May 26, 2016

Good point, that's reasonable, thank you! I can confirm that is also works via injection.

firestarter2prometheus January 20, 2017

Thank you very much for letting us know that and providing a solution. Right now I'm a little bit irritated by the official tutorials that somehow seem to be very outdated and don't make working with Atlassian SDK a breeze sad

Like Ture Hoefner likes this
Roman Samorodov
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 20, 2017

@firestarter2prometheus You can check answer here for modern versions of pom, atlassian-plugin and *.java files  from tutorials

0 votes
Roman Samorodov
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.
December 21, 2016

Found answer HERE.

TAGS
AUG Leaders

Atlassian Community Events