In settings/

ACTIVITI_URL = 'activiti-rest'

In settings/ (after DATABASE):

ACTIVITI_URL = 'activiti-rest-{}'.format(DOMAIN.replace('.', '-')


To deploy, add workflow to your pillar e.g:

# sites/my.sls
    package: hatherleigh_info
    profile: django
    workflow: True

Create a workflow sls:

# config/workflow.sls

And add it to the config for the server e.g:

# top.sls
  - config.workflow




The following notes are for manual install and testing of Activiti (perhaps on your local workstation).


To test Activiti (and create initial tables), find the URL by starting with activiti-rest- and appending your domain name, replacing . with - e.g. for

curl -u kermit:kermit -X GET http://localhost:8080/activiti-rest-www-hatherleigh-info/service/repository/deployments/

To check the logs:

tail -f /var/lib/tomcat7/logs/catalina.out


Install tomcat and dependancies:

sudo apt install tomcat8

The above is all that is required but you can also install:

sudo apt install tomcat8-admin tomcat8-common tomcat8-docs tomcat8-examples tomcat8-user

Download Activiti-6 beta from

Extract the zip and copy the war files activiti-app.war and activiti-rest.war from the wars directory to /var/lib/tomcat8/webapps:

cd <directory expanded activiti to>/wars/
sudo cp activiti-rest.war activiti-app.war /var/lib/tomcat8/webapps/

Start tomcat using the command:

sudo service tomcat8 start

The activiti-app war will be extracted and can be accessed (N.B. default db config assumes mysql database called activitiui with username alfresco, password alfresco:


By default the activiti app uses a mysql database if you want to configure an h2 in memory database:

sudo vim /var/lib/tomcat8/webapps/activiti-app/WEB-INF/classes/META-INF/activiti-app/

Comment out the lines:

# datasource.driver=com.mysql.jdbc.Driver
# datasource.url=jdbc:mysql://
# datasource.username=alfresco
# datasource.password=alfresco

# hibernate.dialect=org.hibernate.dialect.MySQLDialect

Add the lines:


To test access, login in as with password test.

The activiti-rest war will also be extracted (default db config is h2 in memory) you can test access using:

curl -u kermit:kermit -XGET http://localhost:8080/activiti-rest/service/repository/deployments/

Install Tomcat on Windows (incomplete!!)

Download and install java from

Download the tomcat installer from

Double click on the installer to run it. Click “Next >” on the welcome page, then click “I Agree”. On the Choose components page click next On the configuration page Enter a username and password for the adminstrator (don’t think this has to be a windows user)

On the next screen browse to the address of the which you installed the jre

Download Activiti from and expand the zip. From the wars directory copy the activiti-rest.war to the webapps directory of the tomcat installation (e.g. C:Program FilesApache Software FoundationTomcat8webapps). Start tomcat if it is not already running, it will unpack the war file and make the rest api available. You should now be able to use the sample app.

To use Postgresql follow the instructions below


Activiti by default uses uses the h2 in memory database. To use a database that saves data we need to use a different database:

Configure Postgresql (requires jdbc driver, available from I downloaded:


If using tomcat8, copy postgresql-9.4.1212.jar to the lib folder:

sudo cp postgresql-9.4.1208.jar /usr/share/tomcat8/lib/

Assuming your database is called activiti edit:

datasource.username=<activiti user>
datasource.password=<activiti user password>

# PJK, 25/11/2016, I un-commented this line as well

In Activiti REST:

jdbc.username=<activiti user>
jdbc.password=<activiti user password>

Then create a database owned by the <activiti user> specified above:

psql -X -U postgres -c "CREATE DATABASE activiti TEMPLATE=template0 ENCODING='utf-8';"
ALTER USER "<activiti user>" WITH PASSWORD '<activiti user password>';

The PostgreSQL database needs to be configured to accept TCP connections. Our standard pg_hba.conf configuration is as follows:

# /etc/postgresql/9.5/main/pg_hba.conf
local all all trust

When you connect to the database via psql, you are by default using a unix domain socket connection - so the line starting with local applies. If you try to connect via a JDBC driver, the connection will be done via TCP, which means lines starting with host are applicable.

To allow access via TCP, add the following host line to the file:

# /etc/postgresql/9.5/main/pg_hba.conf
host    all         all          md5

Re-start postgres:

service postgresql restart

Re-start tomcat:

sudo service tomcat8 restart

Check for issues in the log files:


Activiti Rest API

The activiti rest api follows the convention of the ‘Services’ in the Java API

Repository Service:


Corresponds to the RepositoryService. This service manipulates the deployments and process definitions

Runtime Service:


Corresponds to the RuntimeService. This service is responsible for manipulating processes e.g. starting a process.

Task Service:


Corresponds to the TaskService. This service is responsible for tasks e.g. completing a task

Form Service:


Corresponds to the FormService. This service is responsible for providing the information that is required for start forms (to start a process) and task forms (to complete a task).

Script Task

We can use a scriptTask to run JavaScript code e.g:

<scriptTask id="sid-32609229" scriptFormat="javascript" activiti:autoStoreVariables="false">
  <script><![CDATA[var secondLevel = parseFloat(secondLevelValue);
    var value = parseFloat(invoiceTotal);
    var firstLevelOnly = value < secondLevel;
    execution.setVariable("firstLevelOnly", firstLevelOnly);]]>

In this example:

  1. We use JavaScript to convert Decimal variables (which are stored as a string) to a float for a value comparison.
  2. secondLevelValue and invoiceTotal are variables in the workflow process. As you can see, it is very easy to access them.
  3. execution.setVariable stores a variable into the workflow. The variable can be used by another task later in the process.

The Workflow App

This consists of a module that encapsulates the activiti rest api (workflow/ and several views that use the api.

Use the module as follows (e.g. to list deployments):

from activiti import Activiti
import json

activiti = Activiti()
response = activiti.deployments()
# response is a dict that contains status information and an element called
# data which contains the
print (json.dumps(response))

The workflow app has an example app called example_workflow.

This currently allows deployment of a workflow and listing of deployments and process definitions. To use the app run ./

Log in as staff

Click on the workflow tab. The current process definitions are displayed. To see available deployments click on “Deployments”

To deploy a new workflow click “New Deployment” browse to a bpmn2.0.xml file and press “submit”

Appendix: Alternative Manual Install Tomcat


You’ll need to install the dependancies (Java runtime etc)

Download version 8 of tomcat zip from and extract to /opt (requires sudo) create a symbolic link to it as follows:

sudo ln -s /opt/apache-tomcat-8.0.33 /opt/tomcat

Install the script tomcat in ~/bin

PATH=$PATH:/opt/tomcat/bin; export PATH

if [ "$1" == "start" ]; then
    processes=`ps -ef | grep catalina | grep "Bootstrap start" | grep -v grep`
    if [ "${processes}" == "" ];then
        if [ `id -u` != 0 ]; then
            echo "Start Tomcat - this script uses sudo - you may need to enter your password"
        sudo /opt/tomcat/bin/ $1
        echo -e "\n\t*** Tomcat already running ***\n"
        echo ${processes}
elif [ "$1" == "stop" ]; then
    processes=`ps -ef | grep catalina | grep "Bootstrap start" | grep -v grep`
    if [ "${processes}" != "" ];then
        if [ `id -u` != 0 ]; then
            echo "Stop Tomcat - this script uses sudo - you may need to enter your password"
            echo "This script uses sudo - you may need to enter your password"
        sudo /opt/tomcat/bin/ $1
        echo -e "\n\t*** Tomcat is not running ***\n"
        echo ${processes}
elif  [ "$1" == "status" ]; then
    ps -ef | grep catalina | grep -v grep
elif  [ "$1" == "restart" ]; then
    $0 stop
    sleep 4
    $0 start
    echo -e "\nUsage\n\t`basename $0` start | stop | status\n"
    exit 2

Starting activiti from manual install

start tomcat using the command:

tomcat start

If you’ve not created the above script you can start using:

sudo /opt/tomcat/bin/ start