Script Runner groovy script giving error as Invalid duplicate class

Hi,

 

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)           ST_Frequency.store();                         }         //Save the changes made above.                 it.store()  }        }

 

 

Suspecting the problem in Script Listeners version 3.0.16

 

Thanks,

Om

 

3 answers

Can I get any help on this issue?

0 vote

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Tuesday in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

118 views 0 4
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