cancel
Showing results for 
Search instead for 
Did you mean: 

Strange behavior Deploy and Start Process

pedrog1
Champ in-the-making
Champ in-the-making
I'm having a strange behavior in my app.

When I reboot my application do I have to redeploy the process definitions? It doesn't make any sense for me, but I try to explain why.

Imagine I've just deployed Activiti. I start my application and upload a process definition

public void deployProcess(string resourceName, InputStream inputStream)
   DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
   deploymentBuilder.name(resourceName);
   deploymentBuilder.addInputStream(resourceName, inputStream);
   deploymentBuilder.deploy();
}
Everything went well. It was deployed and successful parsed.
Then I create a process instance

private void startProcess(String businessKey, String processDefinitionKey) {
   runtimeService.startProcessInstanceByKey(processDefinitionKey, businessKey);
}
It works nicely. I can create as many as I want, complete the task, and so on. No problem till now!

Then I shutdown my app and start it again.
Since I have already deployed the process definition (I can see it in the DB), I can create process instances with it, right?
But when I do

private void startProcess(String businessKey, String processDefinitionKey) {
   runtimeService.startProcessInstanceByKey(processDefinitionKey, businessKey);
}
It gives me this error:

May 29, 2012 6:11:37 PM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.springframework.transaction.TransactionSystemException: JTA failure on resume; nested exception is bitronix.tm.internal.BitronixSystemException: cannot resume a Bitronix Transaction with GTRID [7669616E6F6269732D636C75737465722D6E6F646530000001379994D54500001B7C], status=ACTIVE, 1 resource(s) enlisted (started Tue May 29 18:11:37 WEST 2012), error=XAER_DUPID
   at org.springframework.transaction.jta.JtaTransactionManager.doResume(JtaTransactionManager.java:949)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.resume(AbstractPlatformTransactionManager.java:624)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.cleanupAfterCompletion(AbstractPlatformTransactionManager.java:1017)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:804)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:147)
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.db.DbIdGenerator.getNewBlock(DbIdGenerator.java:42)
   at org.activiti.engine.impl.db.DbIdGenerator.getNextId(DbIdGenerator.java:34)
   at org.activiti.engine.impl.db.DbSqlSession.insert(DbSqlSession.java:104)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.insert(ExecutionEntity.java:1029)
   at org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity.newProcessInstance(ProcessDefinitionEntity.java:137)
   at org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl.createProcessInstanceForInitial(ProcessDefinitionImpl.java:58)
   at org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl.createProcessInstance(ProcessDefinitionImpl.java:48)
   at org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity.createProcessInstance(ProcessDefinitionEntity.java:67)
   at org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity.createProcessInstance(ProcessDefinitionEntity.java:126)
   at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:66)
   at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:31)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
   at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceByKey(RuntimeServiceImpl.java:50)

The strange thing is, if I do this:

//Creates a new deployment, empty! Don't know why, but if not, creating a new process instance will not work!
repositoryService.createDeployment().deploy();

I can then create new process instances and do things normally.

Thanks in advance.
4 REPLIES 4

trademak
Star Contributor
Star Contributor
Hi,

Based on the information you provided I've no idea. Can you post your Activiti Engine config as well?
Can you tell a bit more about your environment and how you've deployed the Activiti Engine?

Best regards,

cweber
Champ in-the-making
Champ in-the-making
I'm not sure but it seems to me as if you are using an in memory version of the database.

Did you use the config script out of the user guide?

If you have
<property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />

change it to the database you use.
If you are using the standard activiti setup (5.9) that should work for you.

<property name="jdbcUrl" value="jdbc:h2:tcp://localhost/activiti" />

pedrog1
Champ in-the-making
Champ in-the-making
Thank you for your replies  Smiley Wink

In my app I'm using Spring with Hibernate

my persistence.xml

(…)
<persistence-unit name="WorkflowPU_3" transaction-type="JTA">
  <provider>org.hibernate.ejb.HibernatePersistence</provider>
  <jta-data-source>java:/comp/env/jdbc/WorkflowDB_3</jta-data-source>
  <exclude-unlisted-classes>true</exclude-unlisted-classes>
  <properties>
   <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />
   <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" />
   <property name="jta.UserTransaction" value="java:comp/UserTransaction" />
   <property name="javax.persistence.transactionType" value="jta" />
   <property name="hibernate.current_session_context_class" value="jta" />
   <property name="hibernate.archive.autodetection" value="none" />
   <property name="hibernate.cache.use_second_level_cache" value="false" />
   <property name="hibernate.query.plan_cache_max_strong_references" value="1024" />
   <property name="hibernate.query.plan_cache_max_soft_references" value="4096" />
   <property name="hibernate.connection.isolation" value="2" />
   <property name="hibernate.connection.release_mode" value="after_statement" />
  </properties>
</persistence-unit>

my applicationcontext.xml

(…)
<!– create BTM transaction manager –>
<bean id="BitronixTransactionManager" factory-method="getTransactionManager" class="bitronix.tm.TransactionManagerServices" destroy-method="shutdown" />
<!– Spring JtaTransactionManager –>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
  <property name="transactionManager" ref="BitronixTransactionManager" />
  <property name="userTransaction" ref="BitronixTransactionManager" />
</bean>

<bean id="entityManagerFactory3" depends-on="BitronixTransactionManager" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  <property name="persistenceUnitName" value="WorkflowPU_3" />
</bean>

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
  <property name="databaseSchemaUpdate" value="true" />
  <property name="transactionManager" ref="transactionManager" />
  <property name="dataSourceJndiName" value="java:/comp/env/jdbc/WorkflowDB_3" />
  <property name="jpaEntityManagerFactory" ref="entityManagerFactory3" />
  <property name="jpaHandleTransaction" value="true" />
  <property name="jpaCloseEntityManager" value="false" />
  <property name="jobExecutorActivate" value="false" />
  <property name="transactionsExternallyManaged" value="true" />
  <property name="history" value="full" />
</bean>

<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
  <property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>

Hope this helps. Thanks  Smiley Happy

pedrog1
Champ in-the-making
Champ in-the-making
I believe I've solved the problem.

I started using the StrongUuidGenerator and so far so good.

For the ones who might having this problem:


<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
  (…)
  <property name="idGenerator">
         <bean class="org.activiti.engine.impl.persistence.StrongUuidGenerator" />
       </property>
      <property name="idBlockSize" value="2000" />
(…)
</bean>
Remember to include java-uuid-generator-3.1.2.jar in your classpath

Regards