Hi,
I'm facing an intermittent issue with ScriptRunner (Jira Data Center) that seems related to class loading / caching.
What is the recommended way to define reusable utility classes in ScriptRunner without hitting this issue?
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.