It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

unable to resolve class com.atlassian.jira.ComponentManager

Just upgraded to Jira 8.1.0 with Adaptavist ScriptRunner for JIRA 5.5.3.1-jira8

Suddenly our ScriptRunner Listeners are failing 100% of time with the following in the logs...

2019-04-10 11:11:16,957 http-nio-80-exec-18 ERROR gstegall 671x20674x1 18lp2y7 10.7.202.3 /secure/QuickEditIssue.jspa [c.o.scriptrunner.runner.AbstractScriptListener] Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: <inline script>
Script123.groovy: 1: unable to resolve class com.atlassian.jira.ComponentManager
2019-04-10 11:11:28,066 http-nio-80-exec-52 ERROR cpfeifer_aa 671x20732x1 10xp4ga 10.7.202.3 /secure/AssignIssue.jspa [c.o.scriptrunner.runner.AbstractScriptListener]

 

When I bring up the script in the editor, it also reports a syntax error on the very first import line for above component. 

Has anyone else experienced this issue?

2 answers

1 accepted

0 votes
Answer accepted

ComponentManager has been deprecated since JIRA 7.11, which is the reason that you cannot resolve this class any longer.

You should migrate to using ComponentAccessor instead, and you may see the API documentation for this class here:

https://docs.atlassian.com/software/jira/docs/api/7.11.0/com/atlassian/jira/component/ComponentAccessor.html

If you have a specific example that uses ComponentManager, feel free to post it here and I'll be happy to show you how you can change it to use ComponentAccessor instead.

How come when I try to import like this....
import com.atlassian.jira.component.ComponentAccessor

it tells me unable to resolve class com.atlassian.jira.component.ComponentAccessor?

I have a script that uses ComponentManager and needs to be converted to use ComponentAccessor instead.

 

// Script to consolidate values from multiple fields to a single field
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.view.CustomFieldParams
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.event.type.EventDispatchOption
import org.apache.log4j.Logger
import org.apache.log4j.Level

// Enable logging
def log = Logger.getLogger("com.jira.copyfieldcontent")
log.setLevel(Level.DEBUG)

// Managers
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def authContext = ComponentAccessor.getJiraAuthenticationContext();

// CustomField ID's
String FieldOneID = "customfield_10603"
String FieldTwoID = "customfield_10403"
String FieldThreeID = "customfield_13346"
String FieldFourID = "customfield_10601"

// DEBUG
//def issue = issueManager.getIssueByCurrentKey("SB-1")


// FieldOne
CustomField FieldOne = customFieldManager.getCustomFieldObject(FieldOneID)
String FieldOneValue = issue.getCustomFieldValue(FieldOne)
log.debug("FieldOneValue:" + FieldOneValue)

// FieldTwo
CustomField FieldTwo = customFieldManager.getCustomFieldObject(FieldTwoID)
String FieldTwoValue = issue.getCustomFieldValue(FieldTwo)
log.debug("FieldTwoValue:" + FieldTwoValue)

// Cascading Select Field
String FieldFourParent = ""
String FieldFourChild = ""
CustomField FieldFour = customFieldManager.getCustomFieldObject(FieldFourID)
Map FieldFourValue = issue.getCustomFieldValue(FieldFour) as Map
if (FieldFourValue) {
FieldFourParent = FieldFourValue.get(null)
FieldFourChild = FieldFourValue.get("1")
}

// Store in description
//String description = "FieldOneValue: " + FieldOneValue + "\n" + "FieldTwoValue: " + FieldTwoValue
//issue.description = description

// Store in FieldThree
String description = ""
description = description + "FieldOneValue: " + FieldOneValue + "\n"
description = description + "FieldTwoValue: " + FieldTwoValue + "\n"
description = description + "FieldFourParent: " + FieldFourParent + ", FieldFourChild: " + FieldFourChild +"\n"

log.debug("Description:" + description)
CustomField FieldThree = customFieldManager.getCustomFieldObject(FieldThreeID)
issue.setCustomFieldValue(FieldThree, description)
issueManager.updateIssue(authContext.getLoggedInUser(),issue, EventDispatchOption.DO_NOT_DISPATCH,false)

 

Can you please have a look at it?

Best Regards

Daniel Miks 

Hello @Daniel Miks,

I saw that the script you posted imports com.atlassian.jira.ComponentManager, but I do not see where the ComponentManager is being used.

After migrating to Jira 8.0, this script will no longer function as the ComponentManager class has been removed. However, all that is needed to change in this script is to remove the import of the component manager. Take care that you don't confuse the ComponentManager class with other managers:

// Managers
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def authContext = ComponentAccessor.getJiraAuthenticationContext();

The above are not using the ComponentManager class - they are separate interfaces, accessed via ComponentAccessor. The ComponentManager class was historically used to access the manager interfaces like so:

ComponentManager componentManager = ComponentManager.getInstance();
delegator = (DelegatorInterface) componentManager.getComponentInstanceOfType(DelegatorInterface.class);

If you would like to make this a separate question so that others can benefit from this answer, you're welcome to do so and I can answer any further questions you have under that post. 

Like # people like this

Hi @Ross McCoy and thank you for your answer.

Suggest an answer

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

Calling all Jira Cloud users! Give us feedback on our exploration of a new navigation.

Hi everyone! My name’s Matt and I’m a product manager at Atlassian. I work in the navigation & findability space for all our Jira Cloud products. We’ve been working on trying to improve the exp...

1,061 views 16 12
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you