Juel Expression Error String Method

Encounter an error when using a standard java string method (startsWith) with JEUL expression:

${javaString.startsWith("somePrefix")}. 

The above expression is used in two different DMN(s), both within the same BPMN. The first DMN has no issue at all when calling the above input JEUL expression. However, when the second DMN called the same JUEL expression. It resulted in the following error message:

2020-04-17 17:26:02,998 [JUnit-ForkJoinPool-1-worker-1] ERROR org.camunda.bpm.engine.context  --- ENGINE-16004 Exception while closing command context: DMN-01002 Unable to evaluate expression for language 'juel': '${JavaString.startsWith("somePrefix")}'
org.camunda.bpm.dmn.engine.impl.DmnEvaluationException: DMN-01002 Unable to evaluate expression for language 'juel': '${JavaString.startsWith("somePrefix")}'
	at org.camunda.bpm.dmn.engine.impl.DmnEngineLogger.unableToEvaluateExpression(DmnEngineLogger.java:35)
	at org.camunda.bpm.dmn.engine.impl.evaluation.ExpressionEvaluationHandler.evaluateElExpression(ExpressionEvaluationHandler.java:121)
....
some more stack trace
....
Caused by: org.camunda.bpm.engine.impl.javax.el.PropertyNotFoundException: Target unreachable, base expression *'. JavaString'* resolved to null
	at org.camunda.bpm.engine.impl.juel.AstMethod.invoke(AstMethod.java:81)
	at org.camunda.bpm.engine.impl.juel.AstMethod.eval(AstMethod.java:75)

At first, it looks like the setting of the DMN of an input variable, I couldn’t find anything abnormal and it doesn’t explain why the same expression worked in the first DMN. I look into several posts about PropertyNotFoundException and I have checked and sure the string pass in is not null and not empty.

Also interestingly, the second DMN actually passing unit testing when the variable is passed into DMN from a CSV file.

If you have any idea what may be causing the error, I greatly appreciate your help!

I’m not sure whether String.startsWith method is supported in JUEL Expressions assuming that javaString was your string variable.
Expression Language was created for simplicity so while it supports a full string match using for example

${javaString == "SomeString"}

supporting all methods of Sting class would have been too much. Refer to the documentation here. It contains link to the official EL documentation.

If you want a startsWith functionality anyhow, I would suggest writing a JavaScript snippet instead of a simple JUEL Expression. Find more help here.

Thank you, the startWith function works. The issue was a variable was not made available to the DMN from the BPMN.