How to import SAL ComponentLocator in a JIRA plugin?

R September 2, 2013

ComponentLocator is discussed at https://developer.atlassian.com/display/DOCS/SAL+Services and said to be available in every Atlassian application.

It seems that accessing a ComponentLocator should be as simple as, in atlassian-plugin.xml:

<component-import key="componentLocator" interface="com.atlassian.sal.api.component.ComponentLocator"/>

...and using constructor dependency injection to get a reference to the ComponentLocator.

When I try this in JIRA 6.0.1, my plugin fails to deploy with:

org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.atlassian.sal.api.component.ComponentLocator] is defined: Unsatisfied dependency of type [class com.atlassian.sal.api.component.ComponentLocator]: expected at least 1 matching bean

I've searched and have not been able to find anyone successfully using the SAL component locator from a JIRA plugin.

I did find http://www.j-tricks.com/1/post/2013/07/component-import-gotchas-nosuchbeandefinitionexception.html which refers to the non-SAL ComponentLocator and talks about confusion between component vs component-import.

Can anyone confirm it as working in JIRA 6, and if so, what's the correct way to get a handle to it?

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
R September 2, 2013

What I was missing is that ComponentLocator's methods are static, so there is no need to import an instance. That's also why I couldn't find a reference to ComponentLocator in anyone's atlassian-plugin.xml.

So, the answer is: yes it works, just call the static methods, nothing is required in atlassian-plugin.xml.

0 votes
HarryH
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.
September 2, 2013

Glad to know it works now, please let me know if you have any questions.

0 votes
HarryH
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.
September 2, 2013

Please see the version matrix https://developer.atlassian.com/display/DOCS/SAL+Version+Matrix, so it should support jira 6

0 votes
HarryH
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.
September 2, 2013

Also please make sure you have deployed the dependency, and please refer to the version number according to https://developer.atlassian.com/display/DOCS/SAL+Version+Matrix

<dependency>
<groupId>com.atlassian.sal</groupId>
<artifactId>sal-api</artifactId>
<version>*</version>
<scope>provided</scope> <!-- Uses the application's SAL instead of bundling it into the plugin. -->
</dependency>
R September 2, 2013

I do have sal-api in my pom.xml as shown here, although my understanding is that it is not expected to actually deploy anything due to the <scope>provided</scope>.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events