A List is converted to an array of Maps in a User Task if multiple forms are used in BPM Suite 6.4

Solution Unverified - Updated -

Environment

  • Red Hat JBoss BPM Suite (BPMS) 6.4.x

Issue

java.lang.ClassCastException: [Ljava.util.Map; cannot be cast to java.util.List exception is thrown by trying to print out a List variable in a Script Task after exiting a User Task node as follows:

The process definition above contains a List variable named list. In ScriptTask1 node the list variable is populated, then new items are added to the list in UserTask node (user task makes use of a multiple form to achieve it). Finally in last ScriptTask2 node the list variable should be printed out, but the error is thrown.

Resolution

A workaround would be to cast variable for an array of Maps as follows:

 java.util.Map[] objects = (java.util.Map[]) kcontext.getVariable("list");

 if (objects != null && objects.length > 0) {

    for(int i = 0; i < objects.length; i++){
    System.out.println(objects[i]);

    } 

 } 

Also, note that the variable is retrieved by using kcontext instance.

Root Cause

Multiple form is converting from a List to an array of Map types. The issue has been reported in RHBPMS-4675 and should be fixed in a future release.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments