I have a webwork action that I'm trying to inject PageBuilderService as well as a custom service class into. It looks like this:
public class CustomAction extends ProjectActionSupport {
@Inject
public CustomAction(@ComponentImport PageBuilderService pageBuilderService,
@ComponentImport CustomService customService) {
...
}
}
According to the spring scanner readme, I should not add the @Scanned annotation to this class, because all classes are scanned by default (I have followed the steps to configure my plugin for Scanner 2.x+). However, omitting it gives me this error when I try to load the url for the action:
No qualifying bean of type [com.atlassian.webresource.api.assembler.PageBuilderService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
Adding @Scanned fixes this (even though it seems like I shouldn't have to do it), BUT it also breaks the injection of my CustomService. The plugin can't even be enabled when building and eventually times out with this error:
Plugin 'com.myplugin' never resolved service '&customService' with filter '(&(objectClass=com.myplugin.CustomService)(objectClass=com.myplugin.CustomService))
My CustomService is a basic service interface for using ActiveObjects, which is implemented as follows:
@Named
public class CustomServiceImpl implements CustomService {
@ComponentImport
private final ActiveObjects activeObjects;
@Inject
public CustomServiceImpl(ActiveObjects activeObjects) {
this.activeObjects = activeObjects;
}
}
I have tried passing parameters to @Named, adding @ExportAsService, none of which seems to help
Basically, I can get the injection of the atlassian class or my class working, but not at the same time.
CustomService must be injected without @ComponentImport annotation. You inject only external to your plugin services with the ComponentService annotation.
public class CustomAction extends ProjectActionSupport {
@Inject
public CustomAction(@ComponentImport PageBuilderService pageBuilderService,
CustomService customService) {
...
}
}
Perfect, can't believe I missed something so simple.
Do you have any idea why the @Scanned annotation is still necessary though, despite the docs?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am not sure about the configurations in your project. But it must work without @Scanned annotation
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.