Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Usage of com.opensymphony.user.UserManager / osuser.xml in JIRA 5 plug-in development

Thomas Heyne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 13, 2013

Hi all,

while converting a plug-in from JIRA 3.13. to JIRA 5.0.5 I run into the following problem.

code snipet:

import com.opensymphony.user.UserManager;
...

    @Override
    public Object getValueFromIssue(CustomField customField, Issue issue) {
        ...
        return getUser(userName);
    }


    private User getUser(String userName) {
        try {
            return UserManager.getInstance().getUser(userName);
        }
        catch (EntityNotFoundException e) {
            logger.error("error finding the user: " + userName);
            e.printStackTrace();
        }
        return null;
    }

maven config:

<dependency>
            <groupId>opensymphony</groupId>
            <artifactId>osuser</artifactId>
            <version>1.0-20060106</version>
        </dependency>

After starting JIRA 5.0.5 witht he plug-in I got the following error:

[com.opensymphony.user.UserManager] Unable to load configuration
com.opensymphony.user.UserManagerImplementationException: The configuration file osuser.xml could not be found.

Afterwards I copied the osuer.xml from WEB-INF/classes of the JIRA 3.13. version tho the WEB-INF/classes of JIRA 5.0.5.

content of osuers.xml:

<provider class="com.atlassian.core.ofbiz.osuser.CoreOFBizCredentialsProvider">
		<property name="exclusive-access">true</property>
	</provider>

	<provider class="com.opensymphony.user.provider.ofbiz.OFBizProfileProvider">
		<property name="exclusive-access">true</property>
	</provider>

	<provider class="com.opensymphony.user.provider.ofbiz.OFBizAccessProvider">
		<property name="exclusive-access">true</property>
	</provider>

After restart of JIRA I got this error:

[opensymphony.user.util.ConfigLoader] Could not create instance of provider
java.lang.ClassNotFoundException: com.atlassian.core.ofbiz.osuser.CoreOFBizCredentialsProvider

In order to avoid this I added to the maven pom.xml now:

<dependency>
            <groupId>com.atlassian.ofbiz</groupId>
            <artifactId>atlassian-ofbiz</artifactId>
            <version>2.7.3</version>
        </dependency>

Unfortunately, this didn't help because I got a NullPointerException in my code now:

java.lang.NullPointerException
	at com.netlinx.plugins.jira.customfields.MyCustomField.getUser(MyCustomField.java:90)

that happens in my code in the following line of my getUser() method

UserManager.getInstance().getUser(userName);

I have no clue why the UserManger returns null ...

Your help is very appreciated. Thanks in advance.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 14, 2013

Ah, that's easy.

You shouldn't be trying to use opensymphony in Jira 5. Don't import it or reference it at all. Undo all the changes you've made in attempting to make it work above, and go back to the Java code.

Replace the import of opensymphony with

import com.atlassian.crowd.embedded.api.User;

You may need to amend more of your user calls as the API for that is a bit different, but it's a starting point.

Thomas Heyne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 14, 2013

ok, thanks
I will start with that ....

probably you meant that I need to have

CrowdService
CrowdDirectoryService
ApplicationProperties

in

UserManager userManager = new DefaultUserManager(crowdService,crowdDirectoryService,applicationProperties);

applicationProperties I have so far, but for the both crowdServices no clue so far ...

Thomas Heyne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 14, 2013
ComponentManager.getInstance().getUserUtil().getUser(userName);

did the job

morareanumihai February 5, 2016

@Nic Brough [Adaptavist]

Hi,

I do not have ComponentManager. Where did you find it?

Thank you in advance ,

Mihai Morareanu

TAGS
AUG Leaders

Atlassian Community Events