Hi Martin,
thank you for your response.
The second way (that is the first one I tried) doesn't work as I expected, ie I'm passing to subprocess B the start user in a variable, that I checked it is properly valued in B. But in this way the subprocess B owner will not be the start user, and this user will not see subprocess B in "My instaces" view of Activiti Explorer.
On the other hand the first way you suggest solved my problem 🙂
For those interested, I modified CallActivityBehavior adding the following few lines of code before the subprocess instantiation:
<java>
…
String pid = execution.getProcessInstanceId();
HistoricProcessInstance hpi = Context
.getProcessEngineConfiguration()
.getHistoryService()
.createHistoricProcessInstanceQuery()
.processInstanceId(pid)
.singleResult();
if (hpi != null) {
execution
.getEngineServices()
.getIdentityService()
.setAuthenticatedUserId(hpi.getStartUserId());
}
PvmProcessInstance subProcessInstance = execution.createSubProcessInstance(processDefinition);
…
</java>