Bug or Feature .... task documentation can not be provided via #{expression}

157 views
Skip to first unread message

Jan Galinski

unread,
Dec 4, 2014, 10:48:56 AM12/4/14
to camunda-...@googlegroups.com
Hi 


In short: I tried to provide the task documentation (description) by defining an expression. Goal: Do not write the description text inside the bpmn-xml but use a code snippet that provides external files or resources.
Problem: I get an exception:

The process could not be started. : Cannot instantiate process definition Process_1:5:1dee07a0-7bc5-11e4-a1a8-b8e85641c4bc: Error while evaluating expression: #{description.get()}. Cause: org.camunda.bpm.engine.cdi.ProcessEngineCdiException: Cannot work with scoped associations inside command context.

Now I wonder ... is it a bug or a feature. Why can I provide the duedate, taskName or the assignee via expressions but not the taskDocumentation? Or am I just doing something wrong?

Robert asked me to ask you, so here I am ... what do you think?

Thanks
Jan

thorben....@camunda.com

unread,
Dec 4, 2014, 10:56:05 AM12/4/14
to camunda-...@googlegroups.com
Hi Jan,

From a quick look at the BPMN parser, expressions are generally supported for the documentation field.

Regarding your concrete problem: Please provide the stack trace and the (simplified) implementation of "description.get()".

Cheers,
Thorben

Jan Galinski

unread,
Dec 4, 2014, 4:02:01 PM12/4/14
to camunda-...@googlegroups.com
Hi Thorben, thanks for the info.

Here is the stack: http://pastebin.com/cTNzRfCH

This is my class:

@Named
@Dependent
public class Description implements Supplier<String> {

@Inject
private BusinessProcess businessProcess;

@Override
public String get() {
return "description for " + businessProcess.getTask().getTaskDefinitionKey();
}
}

and this the bpmn:









<bpmn2:userTask id="UserTask_1" camunda:assignee="#{assignee.get()}" name="Do Something">

      <bpmn2:documentation>#{description.get()}</bpmn2:documentation>

      <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>

      <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>

    </bpmn2:userTask>

assignee works, description doesnt.
I also tried it without the BusinessProcess inject but #{description.get(task}, but with the same result.

Jan

thorben....@camunda.com

unread,
Dec 5, 2014, 4:33:12 AM12/5/14
to camunda-...@googlegroups.com
Hi Jan,

There is multiple things to this:

The reason why you are seeing the exception is that the method businessProcess#getTask always throws an exception when called within an active engine command which is the case here. I updated your bug ticket accordingly to fix this behavior, since for example in a task listener implementation this should work. I updated the ticket you created accordingly.

However, specifying

<bpmn2:documentation>#{description.get()}</bpmn2:documentation>

that internally tries to access the task also does not work because the task entity is still being initialized when the expression is evaluated. Thus, the expression is evaluted against the current execution, not against a task entity (that's also why #{description.get(task)} does not work. And this is in my opinion not a bug. I propose you retrieve the task definition key from the BPMN model instead. For example, something like #{description.get(execution.getBpmnModelElementInstance()} should work. In your bean, you can then use the model API to get the task definition key (which is the activity id anyway, if I am not mistaken. Then you can also use #{description.get(execution.getActivityId)}).

I hope this helps.

Best regards,
Thorben

Jan Galinski

unread,
Dec 5, 2014, 8:13:40 AM12/5/14
to camunda-...@googlegroups.com
Thanks to your answer Thorben, I 
 a) was able to understand whats going on, 
b) solve my problem with your suggested workaround (I used execution.getActivityId())
c) can hope to get an easier way to achieve this in the future since there is a qualified feature request in Jira.

Perfect support!
Have a nice weekend

Jan

Reply all
Reply to author
Forward
0 new messages