ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

使用Camunda流程引擎开发,Cannot resolve identifier ‘assignee‘ 在哪产生,如何解决?

2022-03-11 12:02:04  阅读:262  来源: 互联网

标签:case resolve complete task assignee 任务 Cannot 报错 execution


在使用开源 Camunda 流程引擎框架做二次开发,肯定会遇上报错,这是正常的事件。先不说Camunda ,就算用Spring、 FastJson等等框架都会遇上各种各样的报错,报错不要紧,解决就行了,做程序员不就是这样嘛。解决一个BUG,又产生另外2个BUG。

 

OK,现在回到报错上来。程序报错大多数情况下就这么几种:

  • 空指针

  • 未识别参数

  • 数组越界

在本次的这个报错就属于未识别参数。既然知道了是什么原因,那再进一步乱想,是不是程序某个地方需要这个参数,而又在某个方法里校验的时候又找不到这个参数,所以就抛异常出错了。

为了验证猜想,来进一步跟踪代码! 报这个异常是在点完成任务的时候报的,那继续跟踪即可!

在跟踪代码之前猜想一下需要做什么事情:

  1. 完成当前任务

  2. 完成任务后,根据流程图判断此任务节点后面是否还有用户任务节点。如果有就产生下一个用户任务节点的任务;如果没有,就走到结束ab节点,更新流程结束

带着猜想下面来看看代码是怎么走的

 

这里的 completeTask方法 才是真正的做事。

protected void completeTask(TaskEntity task) {
  // 添加操作日志
  task.logUserOperation(UserOperationLogEntry.OPERATION_TYPE_COMPLETE);
   // 开始真真的做完成任务的事
  task.complete();
}
public void complete() {
  if (TaskState.STATE_COMPLETED.equals(this.lifecycleState) // 任务状态判断
      || TaskListener.EVENTNAME_COMPLETE.equals(this.eventName)
      || TaskListener.EVENTNAME_DELETE.equals(this.eventName)) {
    throw LOG.invokeTaskListenerException(new IllegalStateException("invalid task state"));
  }
  // if the task is associated with a case
  // execution then call complete on the
  // associated case execution. The case
  // execution handles the completion of
  // the task.
  if (caseExecutionId != null) {
    getCaseExecution().manualComplete();
    return;
  }
  // in the other case:
  // ensure the the Task is not suspended   继续判断
  ensureTaskActive();  
  // trigger TaskListener.complete event   
  // 起一个事件监听
  final boolean shouldDeleteTask = transitionTo(TaskState.STATE_COMPLETED);
  // shouldn't attempt to delete the task if the COMPLETE Task listener failed,
  // or managed to cancel the Process or Task Instance
  if (shouldDeleteTask)
  {
    // delete the task
    // this method call doesn't invoke additional task listeners
   // 删除任务
    Context
    .getCommandContext()
    .getTaskManager()
    .deleteTask(this, TaskEntity.DELETE_REASON_COMPLETED, false, skipCustomListeners);
    // if the task is associated with a
    // execution (and not a case execution)
    // and it's still in the same activity
    // then call signal an the associated
    // execution.
    if (executionId !=null) {
      ExecutionEntity execution = getExecution();
      // execution 表删除任务
      execution.removeTask(this);
       // 执行器发送信号 
      execution.signal(null, null);
    }
  }
}

最后跟踪到 执行  activityBehavior.signal(this, signalName, signalData) 这句代码报异常。

 

这行代码的功能是来干嘛呢?发送信号,执行任务

 

最后是在给任务绑定执行人的时候,在参数   VariableScope variableScope 对象没有找到画流程图时定义的 ${assignee},在执行 getValue方法的时候就报异常了。

标签:case,resolve,complete,task,assignee,任务,Cannot,报错,execution
来源: https://blog.csdn.net/weixin_44878554/article/details/123392044

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有