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

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 /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 /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?

5 answers

1 accepted

1 vote
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:

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?

Like Siddesh Mahajan likes this

Here's a script I'm trying to use to convert tasks to sub-tasks but it implements the compoenentManager class. Could you convert it to use the ComponentAccessor?

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.UpdateIssueRequest;

//Examples, 5 is my subtask issue type id. Will be different for others. Can find it in the issue history tab after converting a task to a sub-task
changeToSubTaskAndLink("XXX-8889", "XXX-0000", "5")

//Method to do all the work
def changeToSubTaskAndLink(parentId, childId, subTaskIssueTypeId)
//Get the parent Issue
def parent = ComponentManager.getInstance().getIssueManager().getIssueObject(parentId)
//Get the child Issue
def child = ComponentManager.getInstance().getIssueManager().getIssueObject(childId)
//Change the child to the subtask type
//Update the issue
//Create the subtask link, if this is not done you'll end up with orphans

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")

// 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"

//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.

Hi @Ross McCoy and other guys.

Please help with my short script that add comment in transition:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.comments.CommentManager
import com.opensymphony.workflow.WorkflowContext
import org.apache.log4j.Category

String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();
commmgr = (CommentManager) ComponentManager.getComponentInstanceOfType(CommentManager.class)
commmgr.create(issue, currentUser, "comment text", true)


self-fix ;)

import com.atlassian.jira.component.ComponentAccessor

def jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
def commentManager = ComponentAccessor.getCommentManager()
def user = jiraAuthenticationContext.getLoggedInUser()

"comment text",
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueImpl
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

boolean status = false

IssueManager issueManager = ComponentAccessor.getIssueManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField myCustomField1 = customFieldManager.getCustomFieldObjectByName("TestLead")
CustomField myCustomField2 = customFieldManager.getCustomFieldObjectByName("DesignLead")
String myCustomFieldVal1 = (String) issue.getCustomFieldValue(myCustomField1)
String myCustomFieldVal2 = (String) issue.getCustomFieldValue(myCustomField2)
if(myCustomFieldVal1.equals("Yes") && myCustomFieldVal2.equals("Yes"){
status = true
return status

 Can you please help me convert this. 



Can you help me convert this script?

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.portal.PortalPage
import com.atlassian.jira.portal.PortalPageManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.favourites.FavouritesManager
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("")
def portalPageIds = [10407,10404]
def groupNames = ['teq_jirasd_administrators']
def groupManager = ComponentAccessor.getGroupManager()

ComponentManager componentManager = ComponentManager.getInstance()
PortalPageManager portalPageManager = (PortalPageManager) componentManager.getComponentInstanceOfType(PortalPageManager.class)
FavouritesManager favouritesManager = (FavouritesManager) componentManager.getComponentInstanceOfType(FavouritesManager.class)

for (String groupName: groupNames) {
def grpUserList = groupManager.getUsersInGroup(groupName)
for (ApplicationUser user:grpUserList){
for (Long portalPageId: portalPageIds) {
PortalPage portalPage = portalPageManager.getPortalPageById(portalPageId)
favouritesManager.addFavourite(user, portalPage)"Adding portal " + portalPageId.toString() + " to user: " + user)
} catch (Exception ex){
log.warn("Failed Adding portal " + portalPageId.toString() + " to user: " + user + "\n" + ex)
} //catch
} //for portalID
} //for group users
} //for groups

I'll be happy to help if you can create a new question so you can mark it as the answer appropriately and others can then search for your question and benefit from the knowledge.

Like Peter Cselotei likes this

Suggest an answer

Log in or Sign up to answer

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