IBM Support

Business Process Choreographer -- Restriction when creating the path to the target element in an assign activity

Troubleshooting


Problem

Data manipulation in a business process, modeled with Business Process Execution Language (BPEL), can be done with the help of assign activities. The target of an assign activity can be a variable, a part of a variable, or a subelement of a variable that is described by an XPath location path relative to a variable or variable part. In most cases, when the data element that is specified by an XPath query on the assign-to side is not present, the BPEL engine creates the path to the data object. However, there are certain situations in which the creation fails with the following exception: org.apache.commons.jxpath.JXPathException: Exception trying to create xpath ; JXPath can only create a path if it uses exclusively the child:: and attribute:: axes and has no context-dependent predicates This technote describes this restriction and possible workarounds for it.

Cause

An assignment to a target that does not exist and that is specified with an XPath location path using a dynamic predicate, fails. WebSphere® Process Server uses JXPath to evaluate, set, and create parts of a data object specified by an XPath query. And JXPath cannot create a path that is described by a dynamic location path.

Resolving The Problem


Example:
For example, consider the case of two variables, BO1 and BO2. Both variables contain an array of objects (in this case the array elements are named ID and id). You can use a while loop to iterate over the simple typed variable "counter" of type "xsd:int". The body of the while loop is an assign activity. The assign has two copy statements, the first one copies the nth element of BO1.ID to BO2.id. This assignment is illustrated in the following figure.



The second copy statement increases the counter.

When the target does not exist, the assign fails with the following exception:

org.apache.commons.jxpath.JXPathException: Exception trying to create xpath /id[bpel:getVariableData('counter')]; JXPath can only create a path if it uses exclusively the child:: and attribute:: axes and has no context-dependent predicates
    at org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.createPathAndSetValue(JXPathContextReferenceImpl.java:433)

Possible workarounds:

One solution is to avoid using dynamic information inside predicates. So, instead of using a while loop and dynamic expression, such as "/id[getVariableData('counter')]", you can specify a series of single assignments, each one addressing a specific element in the array, for example: "/id[1]".

However, for example, when initializing arrays with dynamic size, you cannot always use only static predicates. Then, the creation and initialization of the array or data object parts must be done outside the assign activities.

You can use a script activity or a simple SCA service (implemented in Java) to create and initialize the target array. The following shows a code excerpt of a script activity that initializes an array and its elements:

List bo2_id_list = BO2.getList("id");
BOFactory factory =
   (BOFactory)ServiceManager.INSTANCE.locateService("com/ibm/websphere/bo/BOFactory");
BOType boType =
  (BOType)ServiceManager.INSTANCE.locateService("com/ibm/websphere/bo/BOType");
id_type = boType.getType("

http://www.test.com/BO2
", "id");
for (int i=0; i < counter; i++) {
  DataObject aux = factory.createByType(id_type);
  bo2_id_list.add(aux);
}

[{"Product":{"code":"SSQH9M","label":"WebSphere Process Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Business Process Choreographer","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"},{"code":"PF035","label":"z\/OS"}],"Version":"7.0;6.2;6.1.2;6.1","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21222985