I'm trying to inject com.atlassian.jira.user.UserUtils into a REST module type.
I've tried to follow the instructions at https://bitbucket.org/atlassian/atlassian-spring-scanner to no avail.
Here is the code for the module:
@Scanned @Path("/search") public class EmailToNameRest { private final UserUtils userUtils; @Autowired public EmailToNameRest(@ComponentImport UserUtils userUtils) { this.userUtils = userUtils; } @GET @AnonymousAllowed @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response getMessage() { final ApplicationUser user = userUtils.getUser("admin@exmaple.com"); return Response.ok(new EmailToNameRestModel(user.getDisplayName())).build(); } }
When I try and run the module I get either:
[c.a.p.osgi.factory.OsgiPlugin] Detected an error (BundleException) enabling the plugin 'com.wikistrat.jira.emaillogin' : Unresolved constraint in bundle com.wikistrat.jira.emaillogin [177]: Unable to resolve 177.0: missing requirement [177.0] osgi.wiring.package; (osgi.wiring.package=com.atlassian.jira.user.UserUtils).
or
com.wikistrat.jira.emaillogin' - 'emaillogin' failed to load. The plugin has been disabled. A likely cause is that it timed out during initialisation It has the following missing service dependencies : &userUtils of type (&(objectClass=com.atlassian.jira.user.UserUtils)(objectClass=com.atlassian.jira.user.UserUtils))
But I am declaring these items in my pom.xml
<build> <plugins> <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> <!-- Uncomment to install TestKit backdoor in JIRA. --> <!-- <pluginArtifacts> <pluginArtifact> <groupId>com.atlassian.jira.tests</groupId> <artifactId>jira-testkit-plugin</artifactId> <version>${testkit.version}</version> </pluginArtifact> </pluginArtifacts> --> <enableQuickReload>true</enableQuickReload> <enableFastdev>false</enableFastdev> <instructions> <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key> <!-- Add package to export here --> <Export-Package>com.wikistrat.jira.api,</Export-Package> <!-- Add package import here --> <Import-Package> org.springframework.osgi.*;resolution:="optional", org.eclipse.gemini.blueprint.*;resolution:="optional", com.atlassian.jira.user, com.atlassian.jira.user.UserUtils, com.atlassian.jira.*;resolution:="optional", * </Import-Package> <Spring-Context>*</Spring-Context> </instructions> </configuration> </plugin> </plugins> </build>
I've tried using other annotations like @Component instead of @Scanned but it doesn't seem to help.
I've posted the repo at https://bitbucket.org/wsdan/jira-spring-scanner-nolove if someone wants to see the full code.
Any suggestions?
Community moderators have prevented the ability to post new answers.
The root cause of this is that UserUtils is not a component to inject. Try using UserManager.
You probably want to check your Import-Package too. It should not contain any classes, and if you use *, you shouldn't need to include any packages that you use directly.
To help debug these things you can enable verbose output from the spring scanner maven plugin.
You're correct, turns out the issue was that I was trying to import a static class that was in turn relying on UserManager.
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.