Script Runner: using abstract and/or static classes within custom Canned scripts

JIRA 6.3.5

Scriptrunner 3.0.12

I am running into an intermittent issue where I have a custom canned script which subclasses another custom abstract canned script, e.g.: 

package com.onresolve.scriptrunner.canned.jira.workflow.postfunctions
import com.onresolve.scriptrunner.canned.jira.utils.AbstractTransitionIssue
class TransitionSubTasks extends AbstractTransitionIssue

Both classes are custom made and are located in these directories and packages:



It goes without saying AbstractTransitionIssue is subclassed multiple times.


One of the intermittent issues is the "Invalid duplicate class definition of class" exception for the AbstractTransitionIssue class. This exception also occasionally occurs for any custom Helper classes within the com/onresolve/scriptrunner/canned/jira/utils/ directory (these methods are statically used). Sometimes it works and sometimes it does not. 

Another side effect is loading the admin pages "Builtin scripts" and "Custom Listeners" fails with a message "time out - please see logs". 

Usually removing all custom canned scripts from the filesystem directory, restarting JIRA and moving the canned scripts back fixes the issue temporarily. Clearing the Groovy and/or JIRA caches does not clear this issue up. 

Any advice would be very helpful. 

2 answers

I think that must be a configuration issue, because I do this kind of thing hundreds of times a day. Is there some minimal set of classes that you can zip up so that I can try to reproduce?

What are your script roots... are these files in a scripts plugin as well as under a script root?

I've slimmed down the setup to a single class within a single file on the filesystem within the script root /var/atlassian/application-data/jira/scripts. This example class basically subclasses an existing canned script class from the ScriptRunner. 

Here are the steps to reproduce this issue:

  1. Disable and enable the ScriptRunner plugin
  2. Load the Builtin Scripts admin page - verify the scripts are correctly displayed
  3. Load the Script Listeners page - verify listeners are correctly displayed
  4. Place the following file into the file /var/atlassian/application-data/jira/scripts/com/onresolve/scriptrunner/canned/jira/workflow/postfunctions/SubtaskForeach.groovy

    package com.onresolve.scriptrunner.canned.jira.workflow.postfunctions
    public class SubtaskForeach extends CreateSubTask {}
  5. Reload the Script Listeners page - observe the timeout error
  6. Reload the Builtin Scripts page - observe another timeout error

Please note: subclassing another class in the same script root does work as expected. 

Spent some more time investigating, it looks like a classloader issue where the Scriptrunner canned scripts are loaded by one classloader, and the custom canned scripts loaded by another, but this second classloader fails to locate the default canned scripts. This may be due to the fact the default canned scripts and the custom canned scripts are in the same package, but in different locations. If this is the case, how can I specify the classpath for the custom canned scripts?

I am fighting the same issue in JIRA 6.2.1. I have found that if I restart JIRA and load the Built In Scripts page before I load the Scripts Listener page they will both load. I tracked it down to one of our custom scripts being defined as a script listener as well. Once I removed any listener configurations using the custom script the Script Listener page would load every time.

Strangely enough, we upgraded to JIRA 6.4.2, removed and recreated the listeners and the issue is no longer present.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

455 views 8 27
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