Skip to end of banner
Go to start of banner

How to resolve the error: Unable to load FastStringService seen in Groovy scripts with the Scripting for Confluence app

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

\uD83E\uDD14 Problem

java.lang.RuntimeException: Unable to load FastStringService

\uD83C\uDF31 Solution

This error is typically seen when using the Scripting for Confluence app with Groovy scripts that utilize JsonSlurper and JsonOutput. This error can occur due to conflicts with dependencies, preventing the script from executing.

To resolve this error, modify the Groovy script to use JsonSlurperClassic instead of JsonSlurper and JsonOutput. JsonSlurperClassic is a lightweight alternative to the standard JsonSlurper, and it does not require the FastStringService dependency that causes the error.

Here's an example of how to modify the Groovy script:

import groovy.json.JsonSlurperClassic

def json = '''
{
   "name": "John Smith",
   "age": 30
}
'''

def slurper = new JsonSlurperClassic()
def parsedJson = slurper.parseText(json)

log.info(parsedJson.name)

We import the JsonSlurperClassic class instead of the JsonSlurper and JsonOutput classes in the revised script. Then we instantiate a new JsonSlurperClassic object and use it to parse the JSON string.

Using JsonSlurperClassic instead of JsonSlurper and JsonOutput, we avoid the dependency conflict that causes the error. This should allow the script to execute without issue.

Testing this in a test instance before moving it to production is recommended.

  • No labels