In my JIRA plugin, I want to implement a service (which can be scheduled via the Services admin interface) which shall receive required objects via constructor injection, e.g. like this:
@ExportAsService
public class MyPluginService extends AbstractService {
private final SomeHelloWorldInterface helloWorld;
@Inject
public MyPluginService(final SomeHelloWorldInterface helloWorld) {
this.helloWorld = helloWorld;
}
An implementation is also present within my plugin:
@JiraComponent
public class SomeHelloWorldClass implements SomeHelloWorldInterface {
@Override
public String sayHelloWorld() {
return "Hello World!";
}
}
Unfortunately, when trying to activate this as a Service, I receive this error:
- Error adding service: org.picocontainer.injectors.AbstractInjector$UnsatisfiableDependenciesException: com.....impl.MyPluginService has unsatisfied dependency 'interface com.....api.SomeHelloWorldInterface' for constructor 'public com.....impl.MyPluginService(com....api.SomeHelloWorldInterface)' from org.picocontainer.DefaultPicoContainer@7ba6a405:1<[Immutable]:com.atlassian.jira.component.CachingMutablePicoContainer@466051b1.
For whatever reason, the dependency from the Service to the (plugin-internal) component cannot be resolved. I tried several different annotations (e.g. @Autowired), but to no avail.
Any idea what I am doing wrong here? Or does @ExportAsService block plugin-internal dependency resolution?