All Groovy scripts stored in Assets suddenly stopped working with ClassCastException
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
All Groovy scripts stored in Assets suddenly stopped working with ClassCastException. This affects all Groovy scripts in Assets automation rules and post functions, as well as testing a simple script using script console.
Environment
Any Assets version
Diagnosis
Any attempt to run a Groovy script with Assets will fail with exceptions like the following.
From the Assets script console
1
Error: GroovyInsightException: Failed to create Script instance for class: class Script1. Reason: java.lang.ClassCastException: Script1 cannot be cast to groovy.lang.GroovyObject'
insight_automation.log
1
2
2021-07-30 13:56:34,300 [insight-event-6] | AutomationRuleGroovyScriptAction, Unexpected error: Failed to create Script instance for class: class automation.ticketUpdate. Reason: java.lang.ClassCastException: automation.ticketUpdate cannot be cast to groovy.lang.GroovyObject
groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class automation.ticketUpdate. Reason: java.lang.ClassCastException: automation.ticketUpdate cannot be cast to groovy.lang.GroovyObject
Cause
The Java class loading under Jira OSGi trying to find the same Groovy object class under 2 different paths.
Solution
A Jira restart should solve the issue
Was this helpful?