I am trying to use the HAPI API for Scriptrunner and I am getting the following error: 
My code is very simple, I am using the following:
<span> Collection < ProjectComponent > updatedComponentList = issue.getComponents()</span>
<span> updatedComponentList.removeAll(component)</span>
<span> issue.set {
setComponents(updatedComponentList)
}</span>I have found the syntax under this link: https://docs.adaptavist.com/sr4js/latest/hapi/update-issues
Here is my whole code if needed:
<span>package</span> SuperFeature
<span>import</span> com.atlassian.jira.issue.Issue
<span>import</span> org.apache.log4j.Logger
<span>import</span> com.atlassian.jira.project.version.Version
<span>import</span> com.atlassian.jira.bc.project.component.ProjectComponent
<span>import</span> com.atlassian.jira.bc.project.component.ProjectComponentManager
<span>import</span> com.atlassian.jira.security.JiraAuthenticationContext
<span>import</span> com.atlassian.jira.component.ComponentAccessor
<span>import</span> com.atlassian.jira.issue.label.LabelManager
<span>import</span> SuperFeature.Configuration_SuperFeature
<span>import</span> com.adaptavist.hapi.jira.issues.delegate.AbstractIssuesDelegate
<span>def</span> <span>log</span> <span>=</span> Logger.getLogger(<span>'atlassian-jira.log'</span>)
List < ProjectComponent > finalComponentList = <span>new</span> <span>ArrayList</span> < ProjectComponent > ()
<span>int</span> <span>componentSize</span> <span>=</span> issue.getComponents().size()
<span>int</span> generatedIssuesCounter= <span>0</span>
<span>for</span> (ProjectComponent component: issue.getComponents()) {
<span>String</span> <span>componentName</span> <span>=</span> component.getName()
<span>def</span> <span>shortenedComponentName</span> <span>=</span> componentName.substring(componentName.indexOf(<span>"-"</span>) + <span>1</span>)
<span>def</span> <span>projectName</span> <span>=</span> componentName.substring(<span>0</span>, componentName.indexOf(<span>"-"</span>))
<span>if</span>(Configuration_SuperFeature.projectNames.contains(projectName)){
<span>def</span> <span>newIssueproject</span> <span>=</span> ComponentAccessor.projectManager.getProjectObjByKey(projectName)
List < ProjectComponent > newList = <span>new</span> <span>ArrayList</span> < > (newIssueproject.getComponents());
<span>def</span> <span>found</span> <span>=</span> newList.any {
it.getName().equals(shortenedComponentName)
}
<span>if</span> (found) {
finalComponentList.add(component)
generatedIssuesCounter++
}
}
}
createFeature(issue, finalComponentList)
<span>void</span> <span>createFeature</span><span>(Issue issue, Collection < ProjectComponent > componentList)</span> {
<span>JiraAuthenticationContext</span> <span>authenticationContext</span> <span>=</span> ComponentAccessor.getJiraAuthenticationContext();
<span>long</span> <span>issueLinkType</span> <span>=</span> Configuration_SuperFeature.hierarchyIssueLinkType as <span>long</span>
<span>long</span> <span>sequence</span> <span>=</span> Configuration_SuperFeature.sequence as <span>long</span>
<span>long</span> <span>myissueID</span> <span>=</span> issue.getId() as <span>long</span>
<span>// the key of the project under which the version will get created</span>
<span>final</span> <span>String</span> <span>projectKey</span> <span>=</span> Configuration_SuperFeature.projectKey
<span>// the start date - optional</span>
<span>final</span> <span>Date</span> <span>startDate</span> <span>=</span> <span>null</span>
<span>// the release date - optional</span>
<span>final</span> <span>Date</span> <span>releaseDate</span> <span>=</span> <span>null</span>
<span>// a description for the new version - optional</span>
<span>final</span> <span>String</span> <span>description</span> <span>=</span> <span>null</span>
<span>// id of the version to schedule after the given version object - optional</span>
<span>final</span> <span>Long</span> <span>scheduleAfterVersion</span> <span>=</span> <span>null</span>
<span>// true if this is a released version</span>
<span>final</span> <span>boolean</span> <span>released</span> <span>=</span> <span>false</span>
<span>def</span> <span>project</span> <span>=</span> ComponentAccessor.projectManager.getProjectObjByKey(projectKey)
<span>assert</span> project: <span>"Could not find project with key $projectKey"</span>
<span>ProjectComponentManager</span> <span>projectComponentManager</span> <span>=</span> ComponentAccessor.getProjectComponentManager()
Collection < ProjectComponent > updatedComponentList = issue.getComponents()
<span>for</span> (ProjectComponent component: componentList) {
<span>String</span> <span>componentName</span> <span>=</span> component.getName()
<span>def</span> <span>shortenedComponentName</span> <span>=</span> componentName.substring(componentName.indexOf(<span>"-"</span>) + <span>1</span>)
<span>def</span> <span>projectName</span> <span>=</span> componentName.substring(<span>0</span>, componentName.indexOf(<span>"-"</span>))
<span>def</span> <span>newIssueproject</span> <span>=</span> ComponentAccessor.projectManager.getProjectObjByKey(projectName)
List < String > newIssueProjectVersionIDs = <span>new</span> <span>ArrayList</span> < String > ()
newIssueProjectVersionIDs = newIssueproject.getVersions().collect {
it.getName()
}
<span>def</span> <span>customField</span> <span>=</span> ComponentAccessor.getCustomFieldManager().getCustomFieldObject(Configuration_SuperFeature.investmentAreaCustomField);
<span>def</span> <span>value</span> <span>=</span> issue.getCustomFieldValue(customField);
<span>def</span> <span>matchedVersions</span> <span>=</span> issue.getFixVersions().intersect(newIssueproject.getVersions(), Version.NAME_COMPARATOR)
<span>ProjectComponent</span> <span>newComponent</span> <span>=</span> projectComponentManager.findByComponentName(newIssueproject.getId(), shortenedComponentName)
<span>def</span> <span>componentArray</span> <span>=</span> <span>new</span> <span>String</span>[<span>1</span>]
componentArray[<span>0</span>]=newComponent.getName()
<span>def</span> <span>versionCreator</span> <span>=</span> ComponentAccessor.versionManager.&createVersion.rcurry(startDate, releaseDate, description, newIssueproject.id, scheduleAfterVersion, released)
<span>def</span> <span>mynewVersions</span> <span>=</span> issue.fixVersions.intersect(newIssueproject.versions, Version.NAME_COMPARATOR).collect {
versionCreator it.name + <span>'-Inbox'</span>
}
<span>// long newIssueCreatedID = newissue.getId() as long</span>
<span>// def labelManager = ComponentAccessor.getComponent(LabelManager)</span>
<span>// labelManager.addLabel(authenticationContext.getLoggedInUser(), newIssueCreatedID, "SF-Child", false)</span>
<span>// updatedComponentList.removeAll(component)</span>
<span>// projectComponentManager.updateIssueProjectComponents(issue, updatedComponentList)</span>
updatedComponentList.removeAll(component)
<span>// issue.setComponents(updatedComponentList)</span>
<span>// issue.update {</span>
<span>// setComponents(updatedComponentList)</span>
<span>// }</span>
issue.set {
setComponents(updatedComponentList)
}
<span>Issue</span> <span>newissue</span> <span>=</span> Issues.create(projectName, <span>'Feature'</span>) {
setSummary(<span>"["</span>+shortenedComponentName+<span>"] "</span>+issue.getSummary())
setDescription(<span>"This feature has been generated as child of a super feature. Please use this text area to add child feature specific information."</span>)
setReporter(authenticationContext.getLoggedInUser())
setCustomFieldValue(customField.getFieldName(), value)
setFixVersions(mynewVersions as String[])
setComponents (componentArray as String[])
setLabels([<span>"SF-Child"</span>] as String [])
}
newissue.link(Configuration_SuperFeature.hierarchyIssueLinkType, issue)
}
}