Troubleshooting
Problem
A BPEL snippet in a For Each loop is trying to update an array variable but the array is not being updated after the first loop iteration.
Symptom
The output of a For Each loop should be an array of elements, but the array only contains one element.
Cause
The same BPEL variable is being added in each loop iteration.
Diagnosing The Problem
To determine if your BPEL program is affected by this limitation compare it to the following sample. This is a For Each loop that iterates over an array of customers in the input and generates an array of events for output.

The activity Assign CustomerInfo to eventRequest assigns some information to the BPEL variable eventRequest. Then the activity Add eventRequest to ArrayList adds this BPEL variable to an array in another BPEL variable called sendEventRequest in the snippet:

In the first iteration of the loop BPEL creates an instance of eventRequest and it is added to the list normally. Subsequent iterations update the same instance of this variable and when the snippet attempts to add it to the list the attempt fails. There are no warning messages except for the output message seen in the snippet above.
Resolving The Problem
To resolve this problem you must create a new instance of the BPEL variable eventRequest for each iteration of the loop. In the snippet activity Create SendEvent Entities we create all the new variables we need. Highlighted is the variable described in this article.

Was this topic helpful?
Document Information
Modified date:
15 June 2018
UID
swg21517118