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

 Problem

The below article explains how to modify the script to resolve the below error, seen with the Scripting for Confluence app.

java.lang.RuntimeException: Unable to load FastStringService

 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 J