AnsweredAssumed Answered

JUEL Exception evaluating variables with punctuation

Question asked by midiman on Sep 24, 2016
Latest reply on Sep 26, 2016 by warper
I've encountered an issue when setting a juel conditionExpression that contains a period '.'
My sequence flow looks like this: [extract from the model]

<sequenceFlow id="sid-DF4F1F47-4C84-45BE-BF9F-C297DFDC88D3" name="approved" sourceRef="sid-6C005338-CA27-4D4E-B969-BA2410284FFE" targetRef="doapproved">
    <conditionExpression xsi:type="tFormalExpression"><![CDATA[${global.response == allow}]]></conditionExpression>

'global.response' is our own internal namespace name - it's just a variable key.

The salient extract of exception stackTrace I get when the exclusiveGateway that the above sequenceFlow is connected to 'leave's is:

..lots of trace..
Caused by: org.activiti.engine.ActivitiException: Unknown property used in expression: ${global.response == allow}
..lots more irrelevant trace..
Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'global'
   at org.activiti.engine.impl.juel.AstIdentifier.eval(
   at org.activiti.engine.impl.juel.AstBinary$SimpleOperator.eval(
   at org.activiti.engine.impl.juel.AstBinary.eval(
   at org.activiti.engine.impl.juel.AstBinary$SimpleOperator.eval(
   at org.activiti.engine.impl.juel.AstBinary.eval(
   at org.activiti.engine.impl.juel.AstEval.eval(
   at org.activiti.engine.impl.juel.AstNode.getValue(
   at org.activiti.engine.impl.juel.TreeValueExpression.getValue(
   at org.activiti.engine.impl.delegate.ExpressionGetInvocation.invoke(
   at org.activiti.engine.impl.delegate.DelegateInvocation.proceed(
   at org.activiti.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(
   at org.activiti.engine.impl.el.JuelExpression.getValue(

So I had a look at this, half-expecting it to point me to some BeanELContext or similar, but the exception is in the AstBinary evaluator, for which there is no matching AstBinary$SimpleOperator that I can see in the source for a period .

Some javadoc in the Activiti EL evaluators talk about coercing to an Integer or otherwise ignoring. Is there a way to evaluate a processVariable as a String value? - i.e. in sequence flows: 'if this variable is the String "approve" follow this sequence flow'..

Looking at the JUEL spec, it implies that . is used for beans, but then shows examples where regular names are used that contain '.', so the spec is inconclusive in this area.
Also, JUEL doesn't let you 'escape' anything except ${ and #{
(I did try this, but I got this exception:
Caused by: org.activiti.engine.impl.juel.TreeBuilderException: Error parsing '${global\.response == allow}': lexical error at position 8, encountered invalid character '\', expected expression token

So..the question is, how to put a period '.' in a sequenceFlow conditionExpression without the evaluator thinking it's something other than simply a period?
In fact, apart from the obvious operator types ( + - & | / etc.) is it possible to include punctuation (i.e. non-alpahnumeric and non-reserved characters)?

Many thanks for any insights,