AnsweredAssumed Answered

Issue with creating processEngine instance using ProcessEngineConfiguration.buildProcessEngine

Question asked by rajeshbabu_naidu on Sep 16, 2013
Latest reply on Sep 20, 2013 by trademak
Hi,

I'm trying to upgrade from activiti 5.10 to 5.12 to use reports capability but i'm facing an issues while trying to start a custom BPMN process using activiti API.

Below is the java code that i'm using and this was working with 5.10. Please help me.

                                ProcessEngine processEngine = null;
      ProcessEngineConfiguration config = null;
      
      try {
         config = ProcessEngineConfiguration.
               createProcessEngineConfigurationFromResourceDefault();
      } catch (Exception e) {
         e.printStackTrace();
      }
      
      if (config != null) {
         try {
                         processEngine = config.buildProcessEngine();
         } catch (Exception e) {
            e.printStackTrace();
         }
      }

Below is the activiti.cfg.xml

<beans xmlns="http://www.springframework.org/schema/beans
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans  
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<bean id="dbProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="application.properties" />
    <!– Allow other PropertyPlaceholderConfigurer to run as well –>
    <property name="ignoreUnresolvablePlaceholders" value="true"/>
  </bean>
 
  <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
    <property name="databaseType" value="mssql" />
    <property name="processEngineConfiguration" ref="processEngineConfiguration" />
  </bean>
 
  <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
    <property name="dataSource" ref="dataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="databaseSchemaUpdate" value="false" />
    <property name="mailServerHost" value="localhost" />
    <property name="mailServerPort" value="5025" />
    <property name="jobExecutorActivate" value="true" />

  </bean>
 
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />
    <property name="url" value="jdbc:jtds:sqlserver://myserver:1433/activiti" />
    <property name="username" value="username" />
    <property name="password" value="password" />
     <property name="defaultAutoCommit" value="false" />
  </bean>
 
 
 
  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
  </bean>

</beans>


Below is the applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
   xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd">
      
  <import resource="activiti-standalone-context.xml" />
  <import resource="activiti-ui-context.xml" />
 
  <bean id="dbProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="classpath:db.properties" />
    <!– Allow other PropertyPlaceholderConfigurer to run as well –>
    <property name="ignoreUnresolvablePlaceholders" value="true"/>
  </bean>

  <bean id="demoDataGenerator" class="org.activiti.explorer.demo.DemoDataGenerator">
    <property name="processEngine" ref="processEngine" />
  </bean>

  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="${jdbc.driver}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
     <property name="defaultAutoCommit" value="false" />
  </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" />
    <property name="customFormTypes">
      <list>
        <ref bean="userFormType"/>
      </list>
    </property>
  </bean>
 
  <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean" destroy-method="destroy">
     <property name="processEngineConfiguration" ref="processEngineConfiguration" />
  </bean>
 
  <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
  <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
  <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
  <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
  <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
  <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />
 
  <bean id="activitiLoginHandler" class="org.activiti.explorer.ui.login.DefaultLoginHandler">
    <property name="identityService" ref="identityService" />
  </bean>
 
  <!–  Custom form types –>
  <bean id="userFormType" class="org.activiti.explorer.form.UserFormType"/>
 
</beans>

Outcomes