Can't locate the ApplicationLinkService component

I am working on a Jira Plugin (Java), which needs to communicate with a linked Confluence application. I am developing against the atlas-* toolset.

In my plugin, I have this code to get the ApplicationLinkService, and then the link to Confluence:

ApplicationLinkService service = ComponentLocator.getComponent(ApplicationLinkService.class);
ApplicationLink link = service.getPrimaryApplicationLink(ConfluenceApplicationType.class);

This was working fine until recently. Today, theComponentLocator.getComponent() call is returning null.

The applications are still linked correctly as far as I can tell from the Admin GUI. I’ve tried deleting and recreating the link, to no avail.

I’ve tried rolling back changes I’ve made recently, also to no avail. But it’s possible I’m missing something.

It seems bizarre to me that it’s the ApplicationLinkService itself that I can’t find! How is that even possible?

Anyone have any idea how I could have gotten into this mess? And how to get out?

Using ComponentLocator within your code should really be a last resort since you’re asking for all kinds of Osgi “fun”. When was it working recently - or more precise - were you on a particular version of JIRA? Is there are a version of JIRA where it’s not working.

More than likely you’re getting hit with an osgi import issue. If you look in your pom.xml - do you have a code snippet like (note this is for a bitbucket add-on that I’m working on right now so a JIRA add-on will look close to it but not really):

                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>bitbucket-maven-plugin</artifactId>
                                <version>${amps.version}</version>
                                <extensions>true</extensions>
                                <configuration>
                                    <products>
                                        <product>
                                          <id>bitbucket</id>
                                            <instanceId>bitbucket</instanceId>
                                            <version>${bitbucket.version}</version>
                                            <dataVersion>${bitbucket.data.version}</dataVersion>
                                                    </product>
                                                </products>
                                                <instructions>
                                                    <skipManifestValidation>true</skipManifestValidation>
                                                    <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>

If you have the it means that you’re set up to use the spring scanner annotations (which are awesome - but takes a bit of research). If you don’t have the node - then you’re set up to be using the old style method.

If you’re set up with the spring scanner annotations - in your constructor of your class do something like:

@ComponentImport
private final ApplicationLinkService applicationLinkService;
 
@Inject 
public MyClass( final ApplicationLinkService applicationLinkService)
{
    this.applicationLinkService = applicationLinkService;
}

if you’re using the old-style stuff - add a component-import for the ApplicationLinkService and then just add:

public MyClass( final ApplicationLinkService applicationLinkService)
{
    this.applicationLinkService = applicationLinkService;
}

Once you have done that - you should be able to get hold of the ApplictionLinkService (or rather it will be exposed to you).

I do have the Sprig Scanner system set up, and I use it for a number of other components.

            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
                <version>${atlassian.spring.scanner.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>atlassian-spring-scanner</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
                <configuration>
                    <scannedDependencies>
                        <dependency>
                            <groupId>com.atlassian.plugin</groupId>
                            <artifactId>atlassian-spring-scanner-external-jar</artifactId>
                        </dependency>
                    </scannedDependencies>
                    <verbose>false</verbose>
                </configuration>
            </plugin>

However, if I try to inject the ApplicationLinkService this way, my plugin fails to load at all.

I didn’t change my version of Jira in between when it worked and when it didn’t. I did add some dependencies on javax.xml… but I have since removed them in order to get things working again. This hasn’t helped.

Also, FWIW, I see no missing dependencies on the /plugins/servlet/system/console/bundles/ display.