Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Duplicate class error on scriptrunner

Gaston
April 20, 2026

 Hi,

I'm facing an intermittent issue with ScriptRunner (Jira Data Center) that seems related to class loading / caching.

Error

 

Invalid duplicate class definition of class EquipoJira.UtilidadesCampos :
The sources /home/jira/scripts/EquipoJira/UtilidadesCampos.groovy and
file:/home/jira/scripts/EquipoJira/UtilidadesCampos.groovy each contain
a class with the name EquipoJira.UtilidadesCampos.

 

File

 

/home/jira/scripts/EquipoJira/UtilidadesCampos.groovy

 

🧱 Class definition

 

package EquipoJira

public class UtilidadesCampos {
    public static Tuple2<String, String> GetRamoProducto(Issue issue) {}
}

 

📥 Usage

 

import EquipoJira.UtilidadesCampos

UtilidadesCampos.GetRamoProducto(issue)

 Context

  • The class is defined in the ScriptRunner script root.
  • It is used across multiple scripts via import.
  • The error appears intermittently, not consistently
  • There are no duplicate files with the same name in the filesystem.

 

What is the recommended way to define reusable utility classes in ScriptRunner without hitting this issue?

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Slava Dobromyslov
Contributor
April 29, 2026

This is 100% bug in ScriptRunner for Jira Data Center. It recompiles some classes partially and instead of reusing the currently existing loaded classes from the existing class loaders, it creates a separate class loader and loads the same common helper class one more time.

It's really annoying behaviuor. I have not yet filed the bug report, but we must to do it.

I faced the following exception in ScriptRunner 9.33.0:

The following classes appear as argument class and as parameter class, but are defined by different class loader:

my.company.utils.CustomFields (defined by 'groovy.lang.GroovyClassLoader$InnerLoader@11b95554' and 'groovy.lang.GroovyClassLoader$InnerLoader@3a1968f7')

If one of the method suggestions matches the method you wanted to call,

then check your class loader setup. 

 
It's related to my custom helper:

import my.company.utils.CustomFields
...
var value = MyAssetsService.getObjectFromField(issue, CustomFields.SOME_FIELD)


MyAssetsService had one class loader with one CustomFields class, however the calling script was recompiled by ScriptRunner for some reason and received another CustomFields class. So both classes have the same source, but loaded by 2 different class loaders... IDK why ScriptRunner works like this, but it's a huge problem.

0 votes
vikram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 21, 2026

Hi @Gaston 

try this, if it helps 

check below
- Go to ScriptRunner → Settings → Script Roots.
- Ensure only one root path is defined (e.g., /home/jira/scripts).
- Remove duplicates or overlapping paths that point to the same directory.

try
clearing ScriptRunner caches

trying using Consistent Imports
import EquipoJira.UtilidadesCampos

Gaston
April 21, 2026

Thanks. I verified a few things on my side:

There is only a single script path configured: /home/jira/scripts
UtilidadesCampos.groovy contains only one class definition:
package EquipoJira
class UtilidadesCampos { ... }

I am importing it consistently as:
import EquipoJira.UtilidadesCampos

I also confirmed that this file is not being loaded via GroovyShell, evaluate, parseClass, or similar mechanisms

Even with that, the error still appears intermittently:

Invalid duplicate class definition of class EquipoJira.UtilidadesCampos
with the same file being referenced both as a filesystem path and as a file: URL.

Also, clearing ScriptRunner caches several times sometimes makes the issue disappear temporarily, which makes this look more like a classloader/cache invalidation problem than a duplicated file or import issue.

Is this a known issue in ScriptRunner for Jira Data Center?
Are there recommended patterns for reusable helper classes under the script root to avoid this kind of intermittent duplicate class definition error?

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events