AnsweredAssumed Answered

Exception when process is about to end

Question asked by ruben1 on Sep 29, 2011
Latest reply on Oct 13, 2011 by rubensava
Hi,

I've a process doing some things ;). When I complete the last task of this process I get the following exception:


SEVERE: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for org.activiti.persistence.selectJobByQueryCriteria
### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for org.activiti.persistence.selectJobByQueryCriteria
   at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:80)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:72)
   at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:193)
   at org.activiti.engine.impl.persistence.entity.JobManager.findJobsByQueryCriteria(JobManager.java:114)
   at org.activiti.engine.impl.JobQueryImpl.executeList(JobQueryImpl.java:173)
   at org.activiti.engine.impl.AbstractQuery.list(AbstractQuery.java:114)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.remove(ExecutionEntity.java:777)
[…]
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:326)
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:92)
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:49)
   at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(FlowNodeActivityBehavior.java:44)
   at org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.leave(AbstractBpmnActivityBehavior.java:37)
   at org.activiti.engine.impl.bpmn.behavior.ServiceTaskJavaDelegateActivityBehavior.execute(ServiceTaskJavaDelegateActivityBehavior.java:41)
[…]
   at org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.leave(AbstractBpmnActivityBehavior.java:37)
   at org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior.signal(UserTaskActivityBehavior.java:74)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.signal(ExecutionEntity.java:309)
   at org.activiti.engine.impl.persistence.entity.TaskEntity.complete(TaskEntity.java:149)
   at org.activiti.engine.impl.cmd.CompleteTaskCmd.completeTask(CompleteTaskCmd.java:63)
[…]
some code left out in which I call complete cmd on the last task of my process
[…]
Caused by: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for org.activiti.persistence.selectJobByQueryCriteria
   at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:594)
   at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:436)
   at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:428)
   at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:77)
   … 153 more
[…]
same exception logged once more from servlet service…

What I have figured out:

1. it's not my fault! (not that i know)
2. there's no key 'org.activiti.persistence.selectJobByQueryCriteria' in the queried map (obviously)
3. the 'org.apache.ibatis.session.Configuration' gets configured by 'org/activiti/db/mapping/mapping.xml'
4. this leads to 'org/activiti/db/mapping/entity/Job.xml' containing '<select id="selectJobByQueryCriteria" […]/>'

I figured out that this id is the key by which the query can and should be looked up. So why are you looking it up with 'org.activiti.persistence.selectJobByQueryCriteria', which is obviously not working?
Looking into class 'org.activiti.engine.impl.persistence.entity.JobManager' reveals:



[…]

public class JobManager extends AbstractManager {

[…]

  @SuppressWarnings("unchecked")
  public List<TimerEntity> findTimersByExecutionId(String executionId) {
    return getDbSqlSession().selectList("selectTimersByExecutionId", executionId);
  }

  @SuppressWarnings("unchecked")
  public List<Job> findJobsByQueryCriteria(JobQueryImpl jobQuery, Page page) {
    final String query = "org.activiti.persistence.selectJobByQueryCriteria";
    return getDbSqlSession().selectList(query, jobQuery, page);
  }

  @SuppressWarnings("unchecked")
  public List<Job> findJobsByConfiguration(String jobHandlerType, String jobHandlerConfiguration) {
    Map<String, String> params = new HashMap<String, String>();
    params.put("handlerType", jobHandlerType);
    params.put("handlerConfiguration", jobHandlerConfiguration);
    return getDbSqlSession().selectList("org.activiti.persistence.selectJobsByConfiguration", params);
  }

  public long findJobCountByQueryCriteria(JobQueryImpl jobQuery) {
    return (Long) getDbSqlSession().selectOne("org.activiti.persistence.selectJobCountByQueryCriteria", jobQuery);
  }

}

I think all query names prefixed with 'org.activiti.persistence.' will not work 'cause ibatis will have no chance in looking them up.

It's the same in class 'org.activiti.engine.impl.cmd.GetPropertiesCmd':


public class GetPropertiesCmd implements Command<Map<String, String>>, Serializable {

[…]

  @SuppressWarnings("unchecked")
  public Map<String, String> execute(CommandContext commandContext) {
    List<PropertyEntity> propertyEntities = commandContext
      .getDbSqlSession()
      .selectList("org.activiti.persistence.selectProperties");

[…]   

}


Ruben

Outcomes