Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Why is ContainerManager Instance null ?

Harish Kayarohanam January 5, 2014

I started upgrading my JIRA plugin to JIRA v6.1.4 . so I found that import com.opensymphony.user.User; is no more there . so I thought of using crowd user . But I have to use stuff like

user.setFullName and user.setEmail but I found from https://docs.atlassian.com/software/jira/docs/api/4.4.4/deprecated-list.htmlthat it is not possible . so I went by the suggestion there and looked into similar code https://github.com/esoeproject/esoeproject/pull/1/files.

Then I thought of doing something like that and came up with

CrowdService crowdService = getCrowdService();

            User crowdUser = crowdService.getUser(user.getName());

            ImmutableUser.Builder userBuilder = new ImmutableUser.Builder();

            userBuilder.active(crowdUser.isActive());

            userBuilder.directoryId(crowdUser.getDirectoryId());

            userBuilder.name(crowdUser.getName());

            userBuilder.displayName(fullName);

            userBuilder.emailAddress(email);

            try

            {

                  crowdService.updateUser(userBuilder.toUser());

            }

            catch (Throwable t)

            {

            	  smLogger.error("Couldn't update user " + user.getName(), t);

            }
          public CrowdService getCrowdService()
 
            {

               return (CrowdService)ContainerManager.getComponent("crowdService");

            }


But It did not work and found while debugging that it threw NullPOinterException and when I started debugging it took me into ContainerManager.class and there they do

public static Object getComponent(String key) throws ComponentNotFoundException
    {
        return getInstance().getContainerContext().getComponent(key);
    }

but when debugging I went inside getInstance and found that the returned instance itself is null. so I hope that is the problem . so WHY IS CONTAINERMANAGER INSTANCE NULL ?

should I do something to get the instance ? Please help .

3 answers

1 accepted

2 votes
Answer accepted
Boris Georgiev [Appfire]
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.
January 6, 2014

Why not use com.atlassian.jira.component.ComponentAccessor.getCrowdService() ?

0 votes
Harish Kayarohanam January 6, 2014

Thank you very much . I used com.atlassian.jira.component.ComponentAccessor.getCrowdService() and it worked ...Thanks a lot ..

0 votes
Florin Manaila
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.
January 6, 2014

Never used the ContainerManager myself. As a rule of thumb, I usually start off with ComponentAccessor.get<Something>Manager. If that doesn't have it, look for it in ComponentManager.getInstance().get<Something>Manager(), but beware that ComponentManager is deprecated as of JIRA 6, AFAIK. If this fails, then ComponentAccessor.getComponentInstanceOf(Something.class) should do the trick.

HTH

Harish Kayarohanam January 6, 2014

Thanks . Ya I used ComponentAccessor and it started working

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events