Get FieldConfigManager from ComponentAccessor

Ed Sattar September 1, 2013

I am writing a REST plugin . I need FieldConfigManager from ComponentAccessor.

Is this possible or i have to use jira api?

6 answers

1 accepted

2 votes
Answer accepted
Jobin Kuruvilla [Adaptavist]
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.
September 1, 2013

Try this.

FieldConfigManager fieldConfigManager = ComponentAccessor.getComponent(FieldConfigManager.class)

0 votes
RambanamP
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.
September 1, 2013

can you try with this

FieldConfigManager fieldConfigManager = ComponentAccessor.getOSGiComponentInstanceOfType(FieldConfigManager.class)

Ed Sattar September 1, 2013

I tried ComponentAccessor.getComponentOfType same error

RambanamP
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.
September 1, 2013

i have update my anser can you try with that!!

0 votes
Ed Sattar September 1, 2013

import com.atlassian.jira.component.ComponentAccessor;

if (fieldConfigId != null)
{
FieldConfigManager fieldConfigManager = ComponentAccessor.getComponent(FieldConfigManager.class);
fieldConfig = fieldConfigManager.getFieldConfig(fieldConfigId);
}

0 votes
Ed Sattar September 1, 2013

yes i am not injecting anywhere

0 votes
Ed Sattar September 1, 2013

yes i am not injecting anywhere

0 votes
Ed Sattar September 1, 2013

Now I am getting error

ComponentAccessor has not been initialised.

Jobin Kuruvilla [Adaptavist]
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.
September 1, 2013

You are writing a Java plugin, right? Are you sure you are not trying to inject ComponentAccessor anywhere?

RambanamP
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.
September 1, 2013

can you share your code so we can check what is wrong!!

D. U. February 4, 2018

Doing it this way in my SpringBoot application I always get an exception that the ComponentAccessor is not initialized.

  

ComponentAccessor has not been initialised.

 

Can anybody tell me what I have to do that the ComponentAccessor will be properly initialized in a SpringBoot environment? Finally, I want to access the CustomFieldManager to work upon CustomFields...

 ...

customfieldMap.forEach((k, v) -> {
CustomFieldManager cfm = ComponentAccessor.getComponent(CustomFieldManager.class);
CustomField cf = cfm.getCustomFieldObjectByName(k);
System.out.println(cf.getValue((com.atlassian.jira.issue.Issue)v));
...
}
...

 

I get this exception even when I explicitely autowire the ComponentAccessor with 

 private ComponentAccessor componentAccessor;

public void setComponentAccessor(final ComponentAccessor componentAccessor) {
    this.componentAccessor = componentAccessor;
}

...but the ComponentAccessor should be accessed in a static way anyway, shouldn't it!?

Suggest an answer

Log in or Sign up to answer