Hello,
currently we have to use Camunda in the version 7.5. We would like to deploy a DMN-File from an inputStream and evaluate it. The deployment seems to be working, but the evaluation fails with an error in the evaluation-process. (See comment in the code).
Here is the DMN-File (it works in the DMN-Cloud - so it is valid) dmnColor.dmn (1.0 KB)
Here is the code to deploy and evaluate the resource:
String decisionDefinitionKey = "dmnColor";
String decisionDefinitionName = "colorDefinitionName";
// Read the file
InputStream decisionDefinitionStream= this.getClass().getResourceAsStream("/META-INF/dmn/dmnColor.dmn");
// Getting the content of the file in plain-text org.apache.commons.io.IOUtils
String clearTextContent = IOUtils.toString(decisionDefinitionStream, Charset.defaultCharset().name());
decisionDefinitionStream.close();
decisionDefinitionStream = new ByteArrayInputStream(clearTextContent.getBytes(StandardCharsets.UTF_8));
DmnModelInstance dmnModelInstance = Dmn.readModelFromStream(decisionDefinitionStream);
// Validiate the model - works fine
Dmn.validateModel(dmnModelInstance);
// Add .dmn to the file, if it not exists
String resourceName = decisionDefinitionName.endsWith(".dmn") ? decisionDefinitionName : decisionDefinitionName + ".dmn";
/* deploy the resource
The deployment seems to be working, there is a deployment in the database.
Normally we would use addModelInstance, but in version 7.5 this method is not available for DmnInstances. So we ar e using add String*/
this.processEngine.getRepositoryService().createDeployment().name(decisionDefinitionName).addString(resourceName, clearTextContent).deploy();
VariableMap variables = Variables.createVariables().putValue("gender", "female");
// Evaluate the decision - it fails with the error
> org.camunda.bpm.engine.ProcessEngineException: Exception while evaluating decision with key 'dmnColor'
> org.camunda.bpm.dmn.engine.impl.DmnEvaluationException: DMN-01002 Unable to evaluate expression for language 'juel': '${gender}'
DmnDecisionTableResult colorDecisionResult = this.processEngine.getDecisionService().evaluateDecisionTableByKey(decisionDefinitionKey, variables);`
Here is the full stacktrace:
> Caused by: org.camunda.bpm.dmn.engine.impl.DmnEvaluationException: DMN-01002 Unable to evaluate expression for language 'juel': '${gender}' > at org.camunda.bpm.dmn.engine.impl.DmnEngineLogger.unableToEvaluateExpression(DmnEngineLogger.java:32) > at org.camunda.bpm.dmn.engine.impl.DefaultDmnDecisionContext.evaluateElExpression(DefaultDmnDecisionContext.java:329) > at org.camunda.bpm.dmn.engine.impl.DefaultDmnDecisionContext.evaluateExpression(DefaultDmnDecisionContext.java:297) > at org.camunda.bpm.dmn.engine.impl.DefaultDmnDecisionContext.evaluateInputExpression(DefaultDmnDecisionContext.java:217) > at org.camunda.bpm.dmn.engine.impl.DefaultDmnDecisionContext.evaluateInput(DefaultDmnDecisionContext.java:112) > at org.camunda.bpm.dmn.engine.impl.DefaultDmnDecisionContext.evaluateDecisionTable(DefaultDmnDecisionContext.java:93) > at org.camunda.bpm.dmn.engine.impl.DefaultDmnEngine.evaluateDecisionTable(DefaultDmnEngine.java:95) > at org.camunda.bpm.engine.impl.dmn.invocation.DecisionTableInvocation.invoke(DecisionTableInvocation.java:52) > at org.camunda.bpm.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:54) > at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocationInContext(DefaultDelegateInterceptor.java:87) > at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:59) > at org.camunda.bpm.engine.impl.util.DecisionTableUtil.invoke(DecisionTableUtil.java:86) > at org.camunda.bpm.engine.impl.util.DecisionTableUtil.evaluateDecisionTable(DecisionTableUtil.java:81) > at org.camunda.bpm.engine.impl.dmn.cmd.EvaluateDecisionCmd.doEvaluateDecision(EvaluateDecisionCmd.java:72) > ... 48 more > Caused by: org.camunda.bpm.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'gender' > at org.camunda.bpm.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83) > 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:43) > at org.camunda.bpm.dmn.engine.impl.DefaultDmnDecisionContext.evaluateElExpression(DefaultDmnDecisionContext.java:325)
What i’am doing wrong here? The DMN-File is validated successfully, the deployment seems to be working, but if i want to evaluate it, it throws this exception. My input expression in the DMN file is called ‘gender’. The dmn-file is working fine here : Camunda Cloud.
UPDATE: It seems to be, that there is an issue in the bindings in the class > org.camunda.bpm.engine.impl.juel.AstIdentifier:line77 →
method public Object eval(Bindings bindings, ELContext context) { ValueExpression expression = bindings.getVariable(index); // bindings have no variables. So expression contains null;
Maybe there is a bug in the class org.camunda.bpm.engine.impl.juel.TreeValueExpression in line 65?
this.bindings = tree.bind(functions, variables, converter); // Bindings are not set correctly
Additionally i have to say, that we are using the camunda osgi-extension . Can this be a bug from the extension? But the extension is supporting Camunda 7.5…
Thanks a lot for your help!