-
1. Re: Transition rule EL Expression fails
rebody Oct 1, 2010 9:57 PM (in response to dondragon2)Hi Donald,
Which verion of jbpm did you used?
Could you show us a testcase which could re-produce this problem. This will be helpful for investigating it.
Thank you very much.
-
2. Re: Transition rule EL Expression fails
dondragon2 Oct 2, 2010 8:10 AM (in response to rebody)I am using version 4.4
The issue is in the ExpressionCondition class
public boolean evaluate(OpenExecution execution) {
Object result = Expression.create(expression, language).evaluate();
if (result instanceof Boolean) {
return ((Boolean) result).booleanValue();
}
throw new JbpmException("expression condition '" + expression + "' did not return a boolean: " + result);
}
Apparently the value that is returned by the Expression.create is a String " true " which would fail based on the conditions above. I had to modify the code to reflect the following.
public boolean evaluate(OpenExecution execution) {
Object result = Expression.create(expression, language).evaluate();
if (result instanceof Boolean) {
return ((Boolean) result).booleanValue();
}
if (result instanceof String) {
if(result == null)
return false;
return Boolean.valueOf(((String) result).trim());
}
throw new JbpmException("expression condition '" + expression + "' did not return a boolean: " + result);
}
After doing that it is evaluated properly. This an issue that needs to resolved in the official distribution.
public boolean evaluate(OpenExecution execution) {Object result = Expression.create(expression, language).evaluate();if (result instanceof Boolean) {return ((Boolean) result).booleanValue();}if (result instanceof String) {if(result == null)return false;return Boolean.valueOf(((String) result).trim());}throw new JbpmException("expression condition '" + expression + "' did not return a boolean: " + result);} -
3. Re: Transition rule EL Expression fails [Solved]
rebody Oct 2, 2010 8:16 PM (in response to dondragon2)Hi Donald.
Unfortunately, I cannot reproduce this problem, I upload a testcase for this scenario. Could you have a look at it? Thank you very much.
-
4. Re: Transition rule EL Expression fails [Solved]
milnauf Jan 27, 2011 8:41 PM (in response to rebody)Hello,
I running into problems when I try evaluating an expression during runtime (yeah - using internal APIs :s ). What I'm doing is essentially try to find possible execution path using transition's condition.
The problem is that the method org.jbpm.pvm.internal.model.ExpressionCondition.evaluate(OpenExecution execution) - invokes evaluate() on created expression - rather than evaluate(execution). The problem is that the execution variables are not found - because in the subsequent call to JbpmElFactoryImpl.createCompositeResolver - if the scopeInstance is null - which it is in this case - the JbpmVariableElResolver is not added.So a cosmetic change of the org.jbpm.pvm.internal.model.ExpressionCondition evaluate to invoke evaluate with execution parameter rather than without it - should fix the problem. Unless of course there's a good reason for not passing current execution.
At the bottom I attach a stacktrace for the error that I'm getting -> resulting directly from not using the OpenExecution to evaluate the expression.
The resulting code would be similar to the below:
public class org.jbpm.pvm.internal.model.ExpressionCondition {
public boolean evaluate(OpenExecution execution) {
Object result = Expression.create(expression, language).evaluate(execution);
if (result instanceof Boolean) {
return ((Boolean) result).booleanValue();
}
throw new JbpmException("expression condition '" + expression + "' did not return a boolean: "+result);
}
...
}
Stack trace:
javax.el.PropertyNotFoundException: Cannot resolve identifier 'task1'
at de.odysseus.el.tree.impl.ast.AstIdentifier.eval(AstIdentifier.java:86)
at de.odysseus.el.tree.impl.ast.AstEval.eval(AstEval.java:51)
at de.odysseus.el.tree.impl.ast.AstNode.getValue(AstNode.java:28)
at de.odysseus.el.TreeValueExpression.getValue(TreeValueExpression.java:122)
at org.jbpm.pvm.internal.el.UelValueExpression.evaluateInScope(UelValueExpression.java:52)
at org.jbpm.pvm.internal.el.Expression.evaluate(Expression.java:108)
at org.jbpm.pvm.internal.model.ExpressionCondition.evaluate(ExpressionCondition.java:41)
...
caused by a call to:
boolean followPath = transition.getCondition().evaluate(openExecution);