HowTo: Camunda (Tomcat) with MySQL

6,239 views
Skip to first unread message

Carsten Duch

unread,
Apr 8, 2013, 7:16:30 AM4/8/13
to camunda-...@googlegroups.com
I've just switched my camunda BPM (Tomcat) testing environment to MySQL.
I've found no documentation for this, so I've wrote a short HowTo.

1. create MySQL Database
Open a terminal with a MySQL Console as root.
copy&paste the following lines into the console to create a database with the name camundabpm and the password MYSECRETPW (you should change it ...).

CREATE DATABASE IF NOT EXISTS camundabpm;
GRANT ALL ON camundabpm
.* TO camundabpm@'localhost' IDENTIFIED BY 'MYSECRETPW';
GRANT ALL ON camundabpm
.* TO camundabpm@'localhost.localdomain' IDENTIFIED BY  'MYSECRETPW';
GRANT ALL ON camundabpm
.* TO camundabpm@'127.0.0.1' IDENTIFIED BY 'MYSECRETPW';

Close the mysql console and cd into CAMUNDA_DIRECTORY/sql/create and use the following comands in your terminal for the table creation:
$ mysql camundabpm -u camundabpm -pMYSECRETPW <  mysql_cycle_7.0.0-alpha1.sql
$ mysql camundabpm
-u camundabpm -pMYSECRETPW <  mysql_engine_7.0.0-alpha1.sql
$ mysql camundabpm
-u camundabpm -pMYSECRETPW <  mysql_identity_7.0.0-alpha1.sql


2. install MySQL Connector
download the latest version (currently 5.1.24)  of the connector http://mvnrepository.com/artifact/mysql/mysql-connector-java
copy the file mysql-connector-java-5.1.24.jar to the CAMUNDA_DIRECTORY/server/apache-tomcat-7.0.33/lib/ directory

3. change configuration files to work with MySQL instead of H2

open the files:
CAMUNDA_DIRECTORY/server/apache-tomcat-7.0.33/webapps/tasklist/META-INF/maven/org.camunda.bpm.tasklist/camunda-tasklist/pom.xml
CAMUNDA_DIRECTORY/server/apache-tomcat-7.0.33/webapps/cycle/META-INF/maven/org.camunda.bpm.cycle/camunda-cycle/pom.xml
CAMUNDA_DIRECTORY/server/apache-tomcat-7.0.33/webapps/cockpit/META-INF/maven/org.camunda.bpm.cockpit/camunda-cockpit/pom.xml
CAMUNDA_DIRECTORY/server/apache-tomcat-7.0.33/webapps/engine-rest/META-INF/maven/org.camunda.bpm/camunda-engine-rest/pom.xml


and replace the lines:

<dependency>
 
<groupId>com.h2database</groupId>
 
<artifactId>h2</artifactId>
 
<scope>provided</scope>
</dependency>

with:

<dependency>
   
<groupId>mysql</groupId>
   
<artifactId>mysql-connector-java</artifactId>
   
<version>5.1.24</version>
</dependency>


next, open the files:
CAMUNDA_DIRECTORY/server/apache-tomcat-7.0.33/webapps/cycle/META-INF/context.xml
CAMUNDA_DIRECTORY/server/apache-tomcat-7.0.33/conf/server.xml


and replace the lines:

driverClassName="org.h2.Driver"
url
="jdbc:h2:./camunda-h2-dbs/process-engine;MVCC=TRUE;TRACE_LEVEL_FILE=0"
username
="sa"  
password
=""



with:

driverClassName="com.mysql.jdbc.Driver"
url
="jdbc:mysql://localhost:3306/camundabpm?autoReconnect=true"
  username
="camundabpm"  
  password
="MYSECRETPW"


4. start your server

go to CAMUNDA_DIRECTORY/server/apache-tomcat-7.0.33/bin and start the server with the command:

$ ./startup.sh

After the startup, you can take a look into your MySQL Database, inside the table ACT_ID_USER there should be 4 entries for "John","Mary","Peter" and "demo". They are auto-created by the TasklistDemoData.class and this is your confirmation that camunda BPM now uses MySQL instead of H2.

Congratulations!

Daniel Meyer

unread,
Apr 10, 2013, 7:06:07 AM4/10/13
to camunda-...@googlegroups.com
Hi Carsten,

AWESOME! Thanks. We will release an installation guide shortly, maybe we can integrate some of this information there. 

Just one question:
In Step 3 you modify the deployed maven pom.xml files. Why is this necessary?

Chreers,
Daniel

Carsten Duch

unread,
Apr 10, 2013, 7:20:19 AM4/10/13
to camunda-...@googlegroups.com

I just switched from php development to java with play framework last winter.
So I'm new to Maven, I didn't know which files are autogenerated and which not, so I changed everything with "H2" in it :-)

Does this mean that if you change the following files:
CAMUNDA_DIRECTORY/server/apache-tomcat-7.0.33/webapps/cycle/META-INF/context.xml
CAMUNDA_DIRECTORY/server/apache-tomcat-7.0.33/conf/server.xml

the pom.xml files are automatically rewritten? That's a lot easier.

nire....@gmail.com

unread,
Apr 10, 2013, 11:08:24 AM4/10/13
to camunda-...@googlegroups.com
Hi Carsten,

Nice how-to!

As far as I know, changing the any maven coordinates in the poms is not neccessary. Those are just left over for reference (of the expected dependencies) when the maven artifacts are compiled during `mvn install` and have no impact on actual class loading.

I believe it is sufficient to add the mysql drivers (step 2) and reconfigure the database (last step in 3).

Or did you experience any issues with that?

Cheers,

Nico

esie...@gmail.com

unread,
Apr 10, 2013, 5:25:13 PM4/10/13
to camunda-...@googlegroups.com
Hi Carsten,

Another point to add to this is that the h2 JAR should be removed from the tomcat7 lib. Simply renaming it, say, 'mv h2-1.3.168.jar h2-1.3.168.jar.off', works fine. If you don't do this, camunda will still try to create working directories all over the place, such as:
/tmp/hsperfdata_tomcat7/ (replace 'tomcat7' with the userID running your tomcat7 service.)
~tomcat7/camunda-h2-dbs/
and
/usr/share/tomcat7c/bin/camunda-h2-dbs/

Edward Siewick

christian...@gmail.com

unread,
Apr 11, 2013, 5:39:19 AM4/11/13
to camunda-...@googlegroups.com
Hi Carsten,

as Nico pointed out, it is not necessary to do the following stuff, because they are jus meta information generated during the maven build. It is simply ignored during runtime.
Reply all
Reply to author
Forward
0 new messages