cancel
Showing results for 
Search instead for 
Did you mean: 

Exception when process is about to end

ruben1
Champ in-the-making
Champ in-the-making
Hi,

I've a process doing some things Smiley Wink. 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
7 REPLIES 7

ruben1
Champ in-the-making
Champ in-the-making
PS: Is this core related and if so, how does this correlate with 'rock solid'?
PPS: Activiti 5.7

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
I assume you have a small unit test and process definition that demonstrates this problem in a clean, not customized, Activiti using an officially supported database? The reason I ask this is that you seem pretty sure it is not your fault 😉

ruben1
Champ in-the-making
Champ in-the-making
Hi Ronald,

nope, it's /it's not standard activiti (pick one, I haven't found out what the standard might be). It's like that:


  <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
    <property name="driverClass" value="org.postgresql.Driver" />
    <property name="url" value="jdbcSmiley Tongueostgresql://localhost:5432/activiti" />
    <property name="username" value="activiti" />
    <property name="password" value="activiti" />
  </bean>

  <bean id="processEngineConfiguration"
        class="my.custom.JSONFormRenderingProcessEngineConfiguration">
    <property name="dataSource" ref="dataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="databaseSchemaUpdate" value="true" />
    <property name="jobExecutorActivate" value="false" />
    <property name="customFormEngines" ref="customFormEngines" />
  </bean>
 
  <util:list id="customFormEngines">
      <bean class="my.custom.activiti.JSONFormRenderingEngine"/>
  </util:list>
 
  <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
    <property name="processEngineConfiguration" ref="processEngineConfiguration" />
  </bean>

'JSONFormRenderingProcessEngineConfiguration' extends 'SpringProcessEngineConfiguration' and sets  'JSONFormRenderingEngine' as the default form renderer.

And I can reproduce it with a simple process 'Start' -> 'Script Task' setting a process var -> 'End'. The Exception occurs.

Greetz,
Ruben

ruben1
Champ in-the-making
Champ in-the-making
Hi,

I don't know why, but Ibatis does intitialize it's Configuration differently when started in the demo context. I changed the config of the demo's activiti-explorer to match my postgres. No Exception when executing my process.

I changed the configuration of my ProcessEngine to match that of the demo's ProcessEngine:


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlnsSmiley Tongue="http://www.springframework.org/schema/p"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">

  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="org.postgresql.Driver" />
    <property name="url" value="jdbcSmiley Tongueostgresql://localhost:5432/activiti" />
    <property name="username" value="activiti" />
    <property name="password" value="activiti" />
  </bean>

  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
  </bean>

  <bean id="processEngineConfiguration"
        class="org.activiti.spring.SpringProcessEngineConfiguration">
    <property name="dataSource" ref="dataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="databaseSchemaUpdate" value="true" />
    <property name="jobExecutorActivate" value="true" />
  </bean>
 
  <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
    <property name="processEngineConfiguration" ref="processEngineConfiguration" />
  </bean>

<!– Activiti Service Beans –>
[…]
</beans>

No success. Same Exception occurs.

Maybe I do something wrong. At least something is different. The demo calls ProcessEngines.getDefaultProcessEngine() twice on bootstrapping cause of the IdentityService in the applicationContext.xml.

But how can I configure the Ibatis Configuration? What magic allows a successful lookup of the key 'org.activiti.persistence.selectJobCountByQueryCriteria' when running the demo but fails in my environment?

And why is this key in JobManager prefixed with 'org.activiti.persistence.' when no such id is in any of the xml files referenced by 'org/activiti/db/mapping/mappings.xml'? And most of the other classes using the Ibatis mappings have no prefix? Only JobManager.java and GetPropertiesCmd.java have it (and not consistently).

Any clues? Anyone? I don't.

tia,
Ruben

ruben1
Champ in-the-making
Champ in-the-making
Some more infos:

It seems to me, that this is a bug since activiti 5.5  (Upgrade to iBatis 3.0.4).

In revision 2566 the config xmls of ibatis are still under 'src/main/resources/db/ibatis/'

job.mapping.xml:


<mapper namespace="org.activiti.persistence">
[…]

In revision 2602 (ibatis config xmls are now under 'src/main/resources/db/mapping/entity/') job.mapping.xml has been renamed/moved.

Job.xml:


<mapper namespace="org.activiti.engine.impl.persistence.entity.JobEntity">
[…]

This perfectly explains to me why the lookup to 'org.activiti.persistence.selectJobCountByQueryCriteria' fails. Though I still don't know why it succeeds in the demo.

I fixed it for myself by stripping 'org.activiti.persistence.' from the strings in JobManager.java and GetPropertiesCmd.java.
This should be the same and expected behavior (that is: if there is no ambiguity e.g. another '*selectJobCountByQueryCriteria' beeing registered as a MappedStatement). Then iBatis will throw an Exception at me.

Would be great if you could agree with me in that this is a bug and fix this - or tell me that I'm "on the woodway".

After what I've seen in the code this is a refactoring issue.

@Ronald: 'It's not my fault!' - I can only repeat myself. True, it does not happen in the demo setup (which can hardly be seen as THE way to use activiti). And even if you don't officially support Postgresql I don't see any database related issues here. Yeah, yeah it's iBatis and thats database abstraction/management/handling… . But the configuration of iBatis itself should not differ from database to database nor should it be database dependent. At least not if it comes to registering MappedStatements which do not reflect different dialects.

So: it's not my fault! And how does this correlate to rock solid? And do correct me if I'm wrong, mistaken, arrogant, insulting or whatever does legitimately misplease someone.

Ruben

frederikherema1
Star Contributor
Star Contributor
Indeed an issue… However, out unit-tests don't fail even though the methods are used. So beats me why myBatis mapping can find the correct statement.

Will fix on trunk, JIT for the 5.8 release…

rubensava
Champ in-the-making
Champ in-the-making
Hi all,

i have the same issue also yesterday.
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

And then I try to run from activiti-explorer interface, and it works just fine.

So I copy all of the lib in activiti-explorer-5.7\WebContent\WEB-INF\lib to my workspace lib folder.
BAM!!! And the error gone. Smiley Very Happy