Deploy Bonita Community on OpenShift

Do you want to run your Bonita Community Tomcat instance on Redhat’s Openshift Online, using MySQL?

This post will not go into the details of using OpenShift, but rather focus on making Bonita Community Ed. 6.2.4 work on it, along with MySQL. I will not go into details of a regular installation of Bonita either.

Note to Bonita Subscription users: It is currently impossible to run the Subscription Edition on OpenShift (and most likely other PaaS services), due to not being able to generate license requests. Being one of these users, I raised a ticket to Bonita support, but didn’t get much support for it nor any hope to see it in the future.

Pre-requisites

  • Have a free OpenShift account
  • Have deployed an OpenShift application with the MySQL 5.5 and Tomcat 7 (JBoss EWS 2.0) cartridges
  • Downloaded on your workstation the Bonita BPM deployment Bundle

Note: After your git clone, don’t forget to remove the pom.xml from your git root and the src folder in order to avoid triggering a maven build when git pushing your changes.

git rm -r src/ pom.xml

Configuring Bonita the OpenShift way

If you have already deployed Bonita on one of your own server, you will soon notice that you cannot install it the same way using OpenShift.

Don’t forget that for all these local files you’ll modify, you’ll have to git add, git commit, and git push them.

The .openshift folder

After doing your git clone, you will have a local openshift directory (that we’ll call $OPENSHIFT_LOCAL_HOME), along with whatever apps you have. Let’s assign a few variables for this post purposes. Don’t confuse them with variables that you could find on your OpenShift instance:

$OPENSHIFT_LOCAL_HOME=/Users/fblaise/openshift/
$OPENSHIFT_LOCAL_APP=/Users/fblaise/openshift/quarterback

The gem folders are located under $OPENSHIFT_LOCAL_APP/.openshift. In that folder, you will notice 4 folders, 3 being of interest for now.

markers

Make sure you have an empty file named “java7” in it. This will tell your application to use java 7. Without it, you’d be running with java 6.

action_hooks

This is where you will configure the environment variables needed to start your Bonita context.

Create a file named pre_start_jbossews-2.0, and put something along these lines inside:

#!/bin/sh

BONITA_HOME="-Dbonita.home=${OPENSHIFT_DATA_DIR}/bonita_home"
DB_OPTS="-Dsysprop.bonita.db.vendor=mysql"
BTM_OPTS="-Dbtm.root=${OPENSHIFT_REPO_DIR} -Dbitronix.tm.configuration=${OPENSHIFT_REPO_DIR}/.openshift/config/bitronix-config.properties"
export CATALINA_OPTS="${CATALINA_OPTS} ${BONITA_HOME} ${DB_OPTS} ${BTM_OPTS} -Dfile.encoding=UTF-8 -Xshare:auto -XX:+HeapDumpOnOutOfMemoryError"

config

This is the place where you will put your .properties file. This what you should have at the end:

ironman:config fblaise$ ls -l1
bitronix-config.properties
bitronix-resources.properties
catalina.policy
catalina.properties
context.xml
logging.properties
postgresql_module.xml
server.xml
settings.base.xml
settings.prod.xml
settings.rhcloud.xml
settings.stg.xml
tomcat-users.xml
web.xml

Bonita and Tomcat configuration

Local files configuration

Not all files need to be modified. Find below the ones that do.

catalina.properties

In your local config folder under $OPENSHIFT_LOCAL_APP/.openshift, edit the catalina.properties. Locate the line starting with “common.loader”, and append the following:
/var/lib/openshift/xxxxxxxxxxxxxxxxxxxx/app-root/data/lib/*.jar
Note that this string will be unique for each of you. the string of “x” above represents your user for your OpenShift instance. You should then get:

common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,/var/lib/openshift/xxxxxxxxxxxxxxxxxxxx/app-root/data/lib/*.jar

server.xml

Add the following right above the <GlobalNamingResources> tag:


  

I think there is also a H2 listener line you should also remove, since we’re using MySQL. Look in that space also.

context.xml

You will notice a resource that is already configured for MySQL, done when you add the MySQL cartridge. Here, we will add our Bonita datasource and bitronix transaction factory. It should look like this:

[cc lang=”xml”]


[/cc]

bitronix-resources.properties

There is no variable interpolation in this file, so you will have to get your IP address from your OpenShift instance. You will notice in the block below the variables holding the values you’re looking for

[cc lang=”xml”]
resource.ds1.className=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
resource.ds1.driverProperties.user=bonita
resource.ds1.driverProperties.password=bpm
## NOT INTERPOLATING !! resource.ds1.driverProperties.URL=jdbc:mysql://${OPENSHIFT_MYSQL_DB_HOST}:${OPENSHIFT_MYSQL_DB_PORT}/bonita?dontTrackOpenResources=true&amp;amp;amp;amp;amp;amp;useUnicode=true&amp;amp;amp;amp;amp;amp;characterEncoding=UTF-8
resource.ds1.driverProperties.URL=jdbc:mysql://127.4.139.2:3306/bonita?dontTrackOpenResources=true&amp;amp;amp;amp;amp;amp;useUnicode=true&amp;amp;amp;amp;amp;amp;characterEncoding=UTF-8
resource.ds1.testQuery=SELECT 1
[/cc]

Don’t forget to git commit.

war, bonita_home and libraries

webapps

Copy the bonita.war found in your Bonita download in $OPENSHIFT_LOCAL_APP/webapps. git add and commit.

Libraries

There are several ways to go about that one. I will just present the one I use.

– On your openshift instance

mkdir $OPENSHIFT_DATA_DIR/lib

– scp all the .jar files you will find in your Bonita Community download under Tomcat-6.0.37/lib (without the *h2* ones) to the above directory.
– Don’t forget to put in there your MySQL connector jar file as well.

bonita_home

Upload the bonita_home-6.2.4 (containing the client and server subfolders) to your OpenShift instance, straight into $OPENSHIFT_DATA_DIR.

bonita-platform.properties

Don’t forget to change from h2 to mysql

db.vendor=${sysprop.bonita.db.vendor:mysql}

Push and deploy

Everything should now be set.

Make sure you’ve git added and committed all your local files, that your bonita.war in the local webapps directory, that you’ve removed your pom.xml and

git push

Performing a git push will restart your application, albeit all your cartridges.

You can tail the logs straight from your terminal with

rhc tail 

You can check out on your web browser as well, see if the login screen shows. Login with your install user then.

Bonita_BPM_Portal_openshift

Of course, since the application will be out on the wild, don’t forget to change Bonita’s default passwords if not already done (i.e., install user, platformAdmin, etc…).

I may have forgotten some things, as I have written this article some time after doing it. Please let me know if things are missing or are wrong.

Quickly deploy a mongoDB 3-members replica set with vagrant

If you quickly need to test a 3-member mongoDB replica set, this post may be for you.

Using Vagrant and VirtualBox, you can quickly deploy 3 linux servers running mongoDB, automatically configured as a replica set with 1 primary and 2 secondaries. The configuration below is to be used for quick test/dev purposes, not production.

Pre-requisites

Download and install VirtualBox and Vagrant on your computer.

Setup vagrant with initial box image

(Optional if you’re using the Vagrantfile in below tarball)
Open up a terminal and type:
[sourcecode language=’bash’]vagrant init precise64 http://files.vagrantup.com/precise64.box[/sourcecode]

Vagrant config files

Virtualbox (default)

Download this tarball in a place of your liking. Untar it. You can edit them as you see fit, but they should get you started.

Mac OSX / Parallels

Thanks to the vagrant-parallels project, you can install the plugin to run vagrant with parallels.

Run the following commands, and download this Vagrantfile:

vagrant plugin install vagrant-parallels
vagrant box add --provider=parallels precise64 http://download.parallels.com/desktop/vagrant/precise64.box

You can then up your VMs by appending to the vagrant up commands:

--provider=parallels

For more info, see the parallels-plugin website.

Try

Go to the newly created directory, and power everything up from the directory where your Vagrantfile resides.

vagrant up

It is important that “mongo1” gets deployed last, as the provisioning for the replica is done on that node, which will become the master. This is automatic based on the file you just downloaded.

It possible that you get this warning message when the VMs come up:

 The guest additions on this VM do not match the installed version of
VirtualBox! In most cases this is fine, but in rare cases it can
prevent things such as shared folders from working properly. If you see
shared folder errors, please make sure the guest additions within the
virtual machine match the version of VirtualBox you have installed on
your host and reload your VM.

Guest Additions Version: 4.2.0
VirtualBox Version: 4.3

This should not matter. It doesn’t for these specific versions, and for the purpose of this article.

In a matter of minutes, your mongoDB replica set will be ready.

Info

The 3 servers are bound to the following IP addresses (VirtualBox / Parallels)

  • mongo1 : 192.168.33.11 / 10.0.0.11
  • mongo2 : 192.168.33.12 / 10.0.0.12
  • mongo3 : 192.168.33.13 / 10.0.0.13
  • You should end up with the following mongoDB configuration, out of mongo1:

    set0:PRIMARY> rs.conf()
    {
    	"_id" : "set0",
    	"version" : 3,
    	"members" : [
    		{
    			"_id" : 0,
    			"host" : "192.168.33.11:27017"
    		},
    		{
    			"_id" : 1,
    			"host" : "mongo3:27017"
    		},
    		{
    			"_id" : 2,
    			"host" : "mongo2:27017"
    		}
    	]
    }

    Testing with data

    Insert a line for testing, on the primary node:

    set0:PRIMARY> db.something.insert( {test : true} )
    set0:PRIMARY> db.something.find();
    { "_id" : ObjectId("53133ee70a67e2fcfad30e41"), "test" : true }
    

    Now, logon to one of the secondary, and query for that data:

    set0:SECONDARY> db.something.find();
    error: { "$err" : "not master and slaveOk=false", "code" : 13435 }
    

    This is normal. You have to tell Mongo to allow reads on the secondaries.

    set0:SECONDARY> rs.slaveOk()
    
    set0:SECONDARY> db.something.find();
    { "_id" : ObjectId("53133ee70a67e2fcfad30e41"), "test" : true }