Display users in a servlet plugin

Hello everyone,

I am new to the development of plugins in JIRA. We have already managed to create a plugin as a servlet. We have also integrated this into the menu, so that it now appears at the top and with one click the servlet opens.

Now we would like to display a table with logins from JIRA. We don’t want to show all logins, but only 100 accounts that have the JIRA software license. Since we have JIRA Service Desk, we have many other accounts in JIRA (our customers).

In this table with the logins we want to have a text field next to the name where we can write a number. At the end of the table we need a button to save these numbers. The next time we call the plugin, we want to have these numbers in the text fields again.

I know that this is a lot of steps, but first we want to start with the table of users only. On the internet I have already found a solution how to display all users, but that never worked properly. We can get to the current user, but we don’t know how to get all accounts or how to call them in the servlet.

I will try to post the examples we tried later. But maybe somebody already has a good idea.

Option 1

public class AdministrationServlet extends HttpServlet{
    private static final Logger log = LoggerFactory.getLogger(AdministrationServlet.class);

    @JiraImport
    private TemplateRenderer templateRenderer;

    @JiraImport
    private JiraAuthenticationContext authenticationContext;

    @JiraImport
    private UserSearchService userSearchService;

...

    public AdministrationServlet(TemplateRenderer templateRenderer,  JiraAuthenticationContext authenticationContext, UserSearchService userSearchService) {
        this.templateRenderer = templateRenderer;
        this.authenticationContext = authenticationContext;
        this.userSearchService = userSearchService;
     }

Here I get this error when access the sevlet

[INFO] [talledLocalContainer] com.atlassian.util.concurrent.LazyReference$InitializationException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'de.cs.jira.servlet.AdministrationServlet': Unsatisfied dependency expressed through constructor argument with index 2 of type [com.atlassian.jira.bc.user.search.UserSearchService]: No qualifying bean of type [com.atlassian.jira.bc.user.search.UserSearchService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.jira.bc.user.search.UserSearchService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
[INFO] [talledLocalContainer]   at com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:149)
[INFO] [talledLocalContainer]   at com.atlassian.util.concurrent.LazyReference.get(LazyReference.java:112)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.servlet.DefaultServletModuleManager.getInstance(DefaultServletModuleManager.java:447)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.servlet.DefaultServletModuleManager.getServlet(DefaultServletModuleManager.java:426)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.servlet.DefaultServletModuleManager.getServlet(DefaultServletModuleManager.java:238)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.servlet.ServletModuleContainerServlet.service(ServletModuleContainerServlet.java:36)
[INFO] [talledLocalContainer]   at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
[INFO] [talledLocalContainer]   ... 53 filtered
[INFO] [talledLocalContainer]   at com.atlassian.web.servlet.plugin.request.RedirectInterceptingFilter.doFilter(RedirectInterceptingFilter.java:21)
[INFO] [talledLocalContainer]   ... 24 filtered
[INFO] [talledLocalContainer]   at com.atlassian.labs.httpservice.resource.ResourceFilter.doFilter(ResourceFilter.java:59)
[INFO] [talledLocalContainer]   ... 37 filtered
[INFO] [talledLocalContainer]   at com.atlassian.jira.security.JiraSecurityFilter.lambda$doFilter$0(JiraSecurityFilter.java:66)
[INFO] [talledLocalContainer]   ... 1 filtered
[INFO] [talledLocalContainer]   at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:64)
[INFO] [talledLocalContainer]   ... 36 filtered
[INFO] [talledLocalContainer]   at com.atlassian.jira.servermetrics.CorrelationIdPopulatorFilter.doFilter(CorrelationIdPopulatorFilter.java:30)
[INFO] [talledLocalContainer]   ... 10 filtered
[INFO] [talledLocalContainer]   at com.atlassian.web.servlet.plugin.request.RedirectInterceptingFilter.doFilter(RedirectInterceptingFilter.java:21)
[INFO] [talledLocalContainer]   ... 4 filtered
[INFO] [talledLocalContainer]   at com.atlassian.web.servlet.plugin.LocationCleanerFilter.doFilter(LocationCleanerFilter.java:36)
[INFO] [talledLocalContainer]   ... 26 filtered
[INFO] [talledLocalContainer]   at com.atlassian.jira.servermetrics.MetricsCollectorFilter.doFilter(MetricsCollectorFilter.java:25)
[INFO] [talledLocalContainer]   ... 24 filtered
[INFO] [talledLocalContainer]   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[INFO] [talledLocalContainer]   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[INFO] [talledLocalContainer]   at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
[INFO] [talledLocalContainer]   at java.lang.Thread.run(Thread.java:748)
[INFO] [talledLocalContainer] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'de.cs.jira.servlet.AdministrationServlet': Unsatisfied dependency expressed through constructor argument with index 2 of type [com.atlassian.jira.bc.user.search.UserSearchService]: No qualifying bean of type [com.atlassian.jira.bc.user.search.UserSearchService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.jira.bc.user.search.UserSearchService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}```

I guess the problem is, that I can not pass the UserSearchService inside the constructor to my servlet.

Thanks a lot