I'm working on migrating an existing application with Drools 5 to Drools 7. This application process some BPMN workflows. I had success on migration all the application, most of the workflows/processes are working correctly but I have a particular issue when I want to assign a value from a custom java class to a variable in the workflow/process.
So for mapping a variable to another variable We do this. This works fine in Drools 5 and 7.
When we want to assign to a variable, a property from a custom object we do this. This works fine in drools 5 but on drools 7 it throws this exception
org.jbpm.workflow.instance.WorkflowRuntimeException: ... -- unable to execute Assignment at com.xxxx.node.XXXXsWorkItemNodeInstance.processWorkItemHandler(XXXXWorkItemNodeInstance.java:150) at com.xxxxxxx.node.XXXXWorkItemNodeInstance.internalTrigger(XXXXWorkItemNodeInstance.java:119) at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:207) at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:415) at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:393) at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:362)
So this: #{user.name} works in drools 5 but does not in drools 7. Is this feature has to be enable in some way? Like some configuration or something?
Thanks, Angelo
I tried other things like ${user.name} but is not working and I get the same exception.
so I finally realize that Drools 7 is still supporting #{user.name} as a mapping strategy. The problem I had is that when the property does not exists in the object (user.name), Drools 7 throw an exception and stop the whole process while Drools 5 just skip the property and move to the next one.
So I had to override handleAssignment method from ExtendedNodeInstanceImpl class to not throw an exception but logging it.
@Override
protected void handleAssignment(Assignment assignment) {
AssignmentAction action = (AssignmentAction) assignment.getMetaData("Action");
try {
ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime());
context.setNodeInstance(this);
action.execute(this, context);
} catch (Exception e) {
LOGGER.error("[handleAssignment]", e);
// Drools 7 throws a RuntimeException here
}
}