Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,363,022
Community Members
 
Community Events
168
Community Groups

unsatisfied OSGi dependency at runtime for a JIRA Server service class.

hi all,

for our JIRA server installation, I need to create a service which can be modified using the admin page.

It requires the usage of several services and components from the JIRA Agile plugin (formerly Greenhopper)

I do not have an in-depth knowledge of OSGi/Spring.

when I try to configure the service using the JIRA administratore interface I get:


Error adding service: org.picocontainer.injectors.AbstractInjector$UnsatisfiableDependenciesException: com.mtricks.jira.webwork.MyPluginService has unsatisfied dependency 'interface com.atlassian.greenhopper.service.sprint.SprintService' for constructor 'public com.mtricks.jira.webwork.MyPluginService(com.atlassian.greenhopper.service.sprint.SprintService)' from org.picocontainer.DefaultPicoContainer@5705a9b6:1<[Immutable]:com.atlassian.jira.component.pico.CachingMutablePicoContainer@1c68ea0f.
```

but judging by the OSGi browser of my installation, the com.atlassian.greenhopper.service.sprint.SprintService is actually made available by the OSGi

My Assumptions:

  1. my class shall inherit from AbstractService
  2. the required services (SprintService, IssueSprintService, RapidViewService) can only be called via the OSGi mechanism, and not with the ComponentAccessor
  3. in order to use the OSGi mechanism my plugin must declare an Atlassian-Plugin-Key
    (see: https://bitbucket.org/atlassian/atlassian-spring-scanner/src/master/)
  4. declaring an Atlassian-Plugin-Key makes a <Component> declaration in the atlassian-plugin.xml illegal
  5. without <component> declaration, the only way to make my plugin palatable to OSGi is declaring the class a @ExportAsService
  6. the constructor for my plugin's class needs to use the @ComponentImport notation

I am using a standard (and constant) XML to inform Spring of my component:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:atlassian-scanner="http://www.atlassian.com/schema/atlassian-scanner/2"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.atlassian.com/schema/atlassian-scanner/2
http://www.atlassian.com/schema/atlassian-scanner/2/atlassian-scanner.xsd">
<atlassian-scanner:scan-indexes/>
</beans>


My class constructor looks like:

 

@Inject
public MyPluginService(@ComponentImport SprintService sprintService ) {
log = Category.getInstance("SED.JIRA.GENERIC");
log.setLevel(org.apache.log4j.Level.INFO);
this.sprintService = sprintService;
if(sprintService == null) {
log.error("Empty class sprintService");
}
shwc = new SomeHelloWorldClass();


and the class itself is prefixed by:

@ExportAsService (though Ia m not too sure it is needed in the first since I do not care exposing it to other plug-ins).

The pom.xml contains:

<dependency>
<groupId>com.atlassian.jira.plugins</groupId>
<artifactId>jira-greenhopper-api</artifactId>
<version>7.1.19</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.jira.plugins</groupId>
<artifactId>jira-greenhopper-plugin</artifactId>
<version>7.1.19</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-annotation</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>provided</scope>
</dependency>

and

<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<enableQuickReload>true</enableQuickReload>
<enableFastdev>false</enableFastdev>
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
<!-- Add package to export here -->
<Export-Package>com.mtricks,</Export-Package>
<!-- Add package import here -->
<Import-Package>*
</Import-Package>
<Spring-Context>*</Spring-Context>
</instructions>
</configuration>
</plugin>

I am on JIRA server 8.20.8, and my plugin version is 2.

Can anyone tell me if any of my assumptions is wrong, or which error I am making?
Thanks in advance,

Michele

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.20.8
TAGS

Atlassian Community Events