Deploy Activiti Process Explorer on JBoss AS 7

The Activiti process explorer is an handy web application which can be used to manage your processes. It is located into your apps\apache-tomcat-6.0.32\webapps path of your Activiti installation.

In order to enable the deployment of this application on JBoss AS 7 you have:
1) Rename the folder as activiti-explorer.war (so that the AS7 deployer will target is as a web application)


2) Open the applicationContext.xml file which is located in the WEB-INF path of your application and modify it so that it looks like this:

<?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.0.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">

    <bean id="dbProperties"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="classpath:db.properties" />

        <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="com.mysql.jdbc.Driver" />
        <property name="url"
            value="jdbc:mysql://localhost:3306/activiti?autoReconnect=true" />
        <property name="username" value="kermit" />
        <property name="password" value="kermit" />
        <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="mailServerHost" value="localhost" />
        <property name="mailServerPort" value="25" />
        <property name="mailServerUsername" value="fmarchioni" />
        <property name="mailServerPassword" value="fmarchioni" />
        <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>

    <import resource="activiti-ui-context.xml" />

    <bean id="userFormType" class="org.activiti.explorer.form.UserFormType" />

</beans>



Please notice the Datasource section, which contains the MySql settings for the dataSource Bean. In this case, the simplest way to achieve this is to use the org.apache.commons.dbcp.BasicDataSource.

 

Using JBoss AS Datasource

If you don't have to use Apache connection pool and rather want to use JBoss own datasource you have to do a bit more of work, as it will require installing Activiti CDI libraries as well: at first create a datasource on jBoss AS as described in this tutorial:
Then, comment the dataSource bean definition. Instead of it, you will have to reference the datasource through the processEngineConfiguration as shown here:

   <!-- process engine configuration -->
   <bean id="processEngineConfiguration" class="org.activiti.cdi.CdiJtaProcessEngineConfiguration">
      <property name="dataSourceJndiName" value="java:jboss/datasources/MySQLDS" />
      <property name="databaseType" value="mysql" />
      <property name="transactionManager" ref="transactionManager" />
      <property name="transactionsExternallyManaged" value="true" />
      <property name="databaseSchemaUpdate" value="true" />
   </bean>

  <bean id="transactionManager" class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiName" value="java:jboss/TransactionManager"></property>
      <property name="resourceRef" value="true" />
   </bean>


If you try to deploy the Activiti Explorer with this configuration, the deployer will complain that cannot find the java.lang.ClassNotFoundException: org.activiti.cdi.CdiJtaProcessEngineConfigurationNext. As a matter of fact, the new process engine configuration will require CDI dependencies. They are not included in the default Activiti distribution, you have to pick them up using Maven, with the following dependencies:

<dependencies>
    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-cdi</artifactId>
        <version>5.8-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.0.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies> 


Finally, once the application is started up, the activiti-cdi.jar will try to boot the process engine. To accomplish this it will lookup a bean implementing the "ProcessEngineLookup" interface. You will have to provide one, extending LocalProcessEngine lookup, which will create a spring-configured process engine:

public class ProcessEngineConfiguration extends LocalProcessEngineLookup {
}



Well, that was a bit lenghty procedure, however if you want to learn more about it, we suggest you looking at this repository which shows how to set up Activiti + CDI on JBoss 7.1.1:

0
0
0
s2smodern