Cannot access array element in JUEL - bug fixed but not fixed?

Hi,

in my DMN table, I try to use this JUEL expression:
JSON(data).jsonPath("attribute.foo").stringValue().split(" ")[0]

I got the java.lang.Long cannot be cast to java.lang.String error and found that this is a bug described in this ticket CAM-5520 and fixed with with CAM-10232. Fix versions are 7.11.0 and 7.11.0-alpha5.

I downloaded and tried 7.11.0-alpha5, but I still get the same error.

So either my error is not the same as the one treated in the ticket, I made some other mistake or the fix is not included in the version described in the ticket.

I hope, you can enlighten me. Until then, have a nice weekend!

Robin


I’m using camunda-bpm-tomcat-7.11.0-alpha5 on Windows

My DMN:
foobar.dmn (1.1 KB)

My request:

curl --request POST \
  --url http://localhost:8080/engine-rest/decision-definition/key/foobar/evaluate \
  --header 'content-type: application/json' \
  --data '{
    "variables": {
        "data": {
            "type": "json", 
            "value": "{\r\n    \"attribute\": {\r\n        \"foo\": \"b a r\"\r\n    }\r\n}"
        }
    }
}'

First and last part of stack trace as shown in Tomcat console output

24-May-2019 13:41:31.649 WARNING [http-nio-8080-exec-10] org.camunda.bpm.engine.rest.exception.RestExceptionHandler.toResponse org.camunda.bpm.engine.rest.exception.RestException: Cannot evaluate decision foobar:4:db3fb0fd-7e18-11e9-80f9-00ff02ccd4d8: Exception while evaluating decision with key 'null'
        at org.camunda.bpm.engine.rest.sub.repository.impl.DecisionDefinitionResourceImpl.evaluateDecision(DecisionDefinitionResourceImpl.java:159)

...

Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
        at org.camunda.bpm.engine.impl.el.VariableContextElResolver.getValue(VariableContextElResolver.java:43)
        at org.camunda.bpm.engine.impl.javax.el.CompositeELResolver.getValue(CompositeELResolver.java:231)
        at org.camunda.bpm.engine.impl.juel.AstProperty.eval(AstProperty.java:61)
        at org.camunda.bpm.engine.impl.juel.AstEval.eval(AstEval.java:50)
        at org.camunda.bpm.engine.impl.juel.AstNode.getValue(AstNode.java:26)
        at org.camunda.bpm.engine.impl.juel.TreeValueExpression.getValue(TreeValueExpression.java:114)
        at org.camunda.bpm.engine.impl.dmn.el.ProcessEngineElExpression.getValue(ProcessEngineElExpression.java:47)
        at org.camunda.bpm.dmn.engine.impl.evaluation.ExpressionEvaluationHandler.evaluateElExpression(ExpressionEvaluationHandler.java:121)

Hello Robin,

I am not an expert at JUEL so I couldn’t figure out your issue. I am also not sure if the bug was fixed for JUEL. However, I was able to achieve what you were looking for using Javascript. Try the following out.

With the above example I was able to get “a” as the variable output.

Cheers,

Hi,

thanks for pointing out this option! Syntax-wise I like the idea of using JavaScript. What worries me is that Nashorn is deprecated in JDK, but for now, we can use it as a workaround.

It would be great, if anyone had some info on the bug I mentioned.