2

我无法理解正在发生的事情以及为什么我的循环没有继续。我正在为所有打开的活动任务创建一个仪表板。现在我遇到的麻烦是当有人在创建仪表板时关闭任务。

代码是这样的:

List<Task> approvalTasks = taskQueryApproval.list();
for (Task task : approvalTasks) {
    try {
        ActivitiApplicationRequest activitiRequest = (ActivitiApplicationRequest) taskService
                .getVariable(task.getId(), ACTIVITIREQUEST);
        if (!dashboardValues.containsKey(activitiRequest.getGlobalRequestId())) {
            GlobalRequest globalRequest = globalRequestDao
                .findMinimalGlobalRequestForDashboardBySyscode(activitiRequest.getGlobalRequestId());
            if (globalRequest != null) {
                DashboardValueObject vo = new DashboardValueObject(globalRequest);
                vo.setHasApproval(true);
                dashboardValues.put(activitiRequest.getGlobalRequestId(), vo);
            }
        }
        } catch (ActivitiException ex) {
            LOGGER.debug("Approval already done, skipping activititask");
        }
}

我遇到的麻烦是我知道当任务不存在时,Activiti 会抛出异常,这就是为什么我在 for 循环中放置了一个 try-catch。

我期望的是,当错误被捕获时,它只会继续列表的其余部分。在调试时,我什至看到了捕获已完成。但循环仍然中断,应用程序停止。除了这些例外:

SEVERE: Error while closing command context org.activiti.engine.ActivitiException: task 203039 doesn't exist
at org.activiti.engine.impl.cmd.GetTaskVariableCmd.execute(GetTaskVariableCmd.java:55)
at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)

9-nov-2012 14:45:42 org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: com.atomikos.jdbc.AtomikosSQLException: The transaction has timed out - try increasing the timeout if needed
### The error may exist in org/activiti/db/mapping/entity/Task.xml
### The error may involve org.activiti.engine.impl.persistence.entity.TaskEntity.selectTask
### The error occurred while executing a query
### SQL: select * from ACT_RU_TASK where ID_ = ?
### Cause: com.atomikos.jdbc.AtomikosSQLException: The transaction has timed out - try increasing the timeout if needed
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:81)

我究竟做错了什么?

4

0 回答 0