MEL null safe Xpath works in Studio but not Cloudhub

267 views Asked by At

The following expression works fine locally in Studio, but when deployed to Cloudhub it fails with the below error:

Its basically just a simple path expression that uses the null safe ? operator before invoke the .text method. Why doesn't this work in Cloudhub?

    <set-variable variableName="country"
        value="#[xpath('//ns1:root/ns1:Country').?text]"
        doc:name="Set Country" />

Message : Execution of the expression "xpath('//ns1:root/ns1:Country').?text" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: DefaultDocument

Code : MULE_ERROR--2

Exception stack is: 1. null (java.lang.NullPointerException) org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer:363 (null) 2. [Error: null pointer:

1

There are 1 answers

0
Felipe Ocadiz On

Older post but I hope the solution is useful.

Use it this way man:

<set-variable variableName="country" value="#[?xpath('//ns1:root/ns1:Country').text]" doc:name="Set Country" />