Unable to get service JiraUserSessionTracker

Hello, we need to develop a plugin which has to be aware about all currently logged in users and for that we are trying to import an instance of the class JiraUserSessionTracker through a component import annotation:

 

@Named("balancedAssignmentComponent")
public class BalancedAssignmentComponent {
...
@ComponentImport
private final JiraUserSessionTracker jiraUserSessionTracker;
...
@Inject
public BalancedAssignmentComponent(final JiraUserSessionTracker jiraUserSessionTracker,
final UserManager userManager, final GroupManager groupManager, final ProjectRoleManager projectRoleManager,
final ProjectManager projectManager, ...) {
	this.jiraUserSessionTracker = jiraUserSessionTracker;
	this.userManager = userManager;
	this.groupManager = groupManager;
	this.projectRoleManager = projectRoleManager;
	this.projectManager = projectManager;
	...
}

...

}

 

 

When installing the plugin, it fails and throws this error, which does not help us at all to solve the problem:

2016-05-23 12:43:14,141 UpmAsynchronousTaskManager:thread-2 ERROR admin 618x331x2 1v7s77t 0:0:0:0:0:0:0:1 /rest/plugins/1.0/available/featured [c.a.p.osgi.factory.OsgiPlugin] Plugin 'com.xeridia.jira.sigdjira7plugin.SigdJira7plugin' never resolved service '&jiraUserSessionTracker' with filter '(&(objectClass=com.atlassian.jira.web.session.currentusers.JiraUserSessionTracker)(objectClass=com.atlassian.jira.web.session.currentusers.JiraUserSessionTracker))'
2016-05-23 12:43:14,144 UpmAsynchronousTaskManager:thread-2 DEBUG admin 618x331x2 1v7s77t 0:0:0:0:0:0:0:1 /rest/plugins/1.0/available/featured [c.a.activeobjects.osgi.ActiveObjectsServiceFactory] onPluginDisabledEvent removing delegate for [com.xeridia.jira.sigdjira7plugin.SigdJira7plugin]
2016-05-23 12:43:14,146 UpmAsynchronousTaskManager:thread-2 ERROR admin 618x331x2 1v7s77t 0:0:0:0:0:0:0:1 /rest/plugins/1.0/available/featured [c.a.plugin.manager.PluginEnabler] Unable to start the following plugins due to timeout while waiting for plugin to enable: com.xeridia.jira.sigdjira7plugin.SigdJira7plugin

 

What does that mean? I think it is absolutely senseless.

1 answer

1 accepted

This widget could not be displayed.
Chris Fuller Atlassian Team May 23, 2016

The JiraUserSessionTracker is not part of the JIRA API.  It is only available by using jira-core, and you cannot get it injected to a plugin, because it is not intended for third-party use.

There is probably something in jira-api that does what you need.  However, if there is not, then the only way you can use this is:

  • Add a dependency on jira-core
  • Obtain it using ComponentAccessor.getComponent(JiraUserSessionTracker.class)

Any use of jira-core is, however, not covered by the Java API Policy for JIRA.  It may break at any time, even in a bugfix release. 

Thank you for your fast response. Respecting to the jira-core usage I am aware of what you are stating. I were already able to use that service by adding this line of code to my class:

private final JiraUserSessionTracker jiraUserSessionTracker = JiraUserSessionTracker.getInstance();

It is only an instance attribute and initializing it this way is working for me. I suppose that using the component accessor would work the same.

Chris Fuller Atlassian Team May 23, 2016

It would turn up the same result.  That's actually what getInstance() calls internally:

public static JiraUserSessionTracker getInstance() {
    return ComponentAccessor.getComponentOfType(JiraUserSessionTracker.class);
}
Chris Fuller Atlassian Team May 23, 2016

Unfortunately, a quick search of the API turned up... nothing.  There doesn't seem to be an API-safe way to find out who is logged in.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

28 views 0 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you