I am firing an event based on a transition called "Generate Features" executed as you can see below:

Also, based on an automation rule, I am executing some code. Here is the automation rule that I have:
The problem is that I am getting a message saying that the issue does not have an component which is wrong since the issue that I am testing my code on has 2 components as you can see below:
Here is the code to be executed as part of the automation rule:
package SuperFeature
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Logger
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.bc.project.component.ProjectComponentManager
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager
def log = Logger.getLogger('atlassian-jira.log')
List < String > componentList = new ArrayList < String > ()
List < ProjectComponent > finalComponentList = new ArrayList < ProjectComponent > ()
def projectNames = [ 'WF', 'BF', 'EF', 'YF', 'CLTF']
log.warn("=====MOUNA CAMELIA ISSUE:::: "+ issue +" ISSUE COMPONENTS "+issue.getComponents())
if (issue.getComponents().size() == 0) {
issue.update {
String text = "Issue does not have any components\n"
setCustomFieldValue('Execution Summary', text )
}
} else if (issue.getFixVersions().size() == 0) {
issue.update {
String text = "Issue does not have any fix versions\n"
setCustomFieldValue('Execution Summary', text)
}
} else {
int componentSize = issue.getComponents().size()
int generatedIssuesCounter= 0
for (ProjectComponent component: issue.getComponents()) {
String componentName = component.getName()
def shortenedComponentName = componentName.substring(componentName.indexOf("-") + 1)
def projectName = componentName.substring(0, componentName.indexOf("-"))
if(projectNames.contains(projectName)){
def newIssueproject = ComponentAccessor.projectManager.getProjectObjByKey(projectName)
//log.warn("MOUNA CAMELIA found--"+found+"--NEW LIST SIZE: "+newList)
List < ProjectComponent > newList = new ArrayList < > (newIssueproject.getComponents());
def found = newList.any {
it.getName().equals(shortenedComponentName)
}
if (found) {
componentList.add(componentName+" ===> WILL BE GENERATED")
finalComponentList.add(component)
generatedIssuesCounter++
} else{
componentList.add(componentName+" ===> CANNOT BE GENERATED")
}
}
}
issue.update {
String text = "The super feature " + issue + " will be split into " + generatedIssuesCounter + " features, one for each component:\n"
text = text + componentList.join("\n") ;
// Partition a list into list of lists size 3
setCustomFieldValue('Execution Summary', text)
}
}
