Java 捕获的ActivityException仍会被抛出并中断应用程序
我很难理解发生了什么以及为什么我的循环没有继续。我正在为所有打开的activiti任务创建仪表板。现在我遇到的麻烦是,在创建仪表板时,有人关闭了任务 代码如下所示:Java 捕获的ActivityException仍会被抛出并中断应用程序,java,activiti,atomikos,Java,Activiti,Atomikos,我很难理解发生了什么以及为什么我的循环没有继续。我正在为所有打开的activiti任务创建仪表板。现在我遇到的麻烦是,在创建仪表板时,有人关闭了任务 代码如下所示: List<Task> approvalTasks = taskQueryApproval.list(); for (Task task : approvalTasks) { try { ActivitiApplicationRequest activitiRequest = (ActivitiAp
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");
}
}
我做错了什么?您的服务是@Transactional吗?事务已超时。听起来你的数据库有锁问题。@willome调用的服务本身来自Activiti。现在在源代码中我没有看到注释。引发ActivityException后,超时立即出现。请检查调试日志。你看到回滚了吗?@willome是的,在事务超时后,它也会触发回滚。是的,我正在使用Spring。你能试着添加一个带有“norollbackfor”ActivitieException的@transactional吗
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)