Script Runner groovy script giving error as Invalid duplicate class



We have script where script console running fine but when I place in script runner then getting the error as below


"Invalid duplicate class definition of class "


Detailed Error:


Problem loading class: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: D:\Atlassian\JIRA\scripts\listener\SubTaskUpdateScript.groovy: 20: Invalid duplicate class definition of class SubTaskUpdateScript: The sources D:\Atlassian\JIRA\scripts\listener\SubTaskUpdateScript.groovy and file:/D:/Atlassian/JIRA/scripts/listener/SubTaskUpdateScript.groovy each contain a class with the name SubTaskUpdateScript. @ line 20, column 1.   ComponentManager componentManager = ComponentManager.getInstance()   ^ 1 error
It is Strange for me. I dig into the code but did not find any duplicate class in it. Here is the code that I am using.


import com.atlassian.jira.ComponentManager import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.IssueManager import com.atlassian.jira.issue.customfields.manager.OptionsManager import com.atlassian.jira.issue.util.DefaultIssueChangeHolder import com.atlassian.jira.issue.customfields.option.* import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.config.SubTaskManager
ComponentManager componentManager = ComponentManager.getInstance() CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
OptionsManager optManager = ComponentAccessor.getOptionsManager();
def PT_CfName = customFieldManager.getCustomFieldObjectByName("Frequency") def PT_CfVal = issue.getCustomFieldValue(PI_CfName).getValue() def fieldConfig = PT_CfName.getRelevantConfig(issue)
// Getting the option selected in Parent Task for Frequency Field def option = optManager.getOptions(fieldConfig).find {it.toString() == PT_CfVal}
// Defining Subtask SubTaskManager subTaskManager = componentManager.getSubTaskManager(); Collection subTasks = issue.getSubTaskObjects() if (subTaskManager.subTasksEnabled && !subTasks.empty) {     subTasks.each {                  //Set the Frequency if changed.        CustomField ST_Frequency = customFieldManager.getCustomFieldObjectByName('Frequency')               S_FreqVal = it.getCustomFieldValue(ST_Frequency)        if(ST_Frequency != PT_CfVal){           DefaultIssueChangeHolder issueChangeHolder = new DefaultIssueChangeHolder();           ST_Frequency.updateValue(null,it,new ModifiedValue(S_FreqVal,option),issueChangeHolder) ;                         }         //Save the changes made above.         }        }



Suspecting the problem in Script Listeners version 3.0.16





3 answers

Can I get any help on this issue?

Did you copy this from another question?

Your scripts should be in the "scripts" sub-directory under the JIRA home directory. Also if it's in a directory under that, in your case "listeners", you need a "package listeners" line at the top.

Hi Jamie,


I kept "package listeners" line at the top of the script and did update. Its updated without error but when I reopen it and click on preview or update then getting the same error. Am I missing any thing else?



Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


236 views 0 6
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you