Version 6

    This article provides a simple technique for creating and populating the jBPM 3.2 database using hibernate, running against any database server supported by hibernate.


    There are frequent questions on the jBPM forum regarding how to get jBPM working outside

    of jBoss, in particular with Tomcat, but presumably with other java serlet/application

    servers like Jetty and Resin. To that end, one of the first things which has to be done is to create the jBPM database. There

    are SQL scripts provided with the Starter Kit that are supposed to accomplish this for any given

    database which is supported by hibernate, but the scripts don't always work, and

    specifically, they do not create the jBPM Identity database, which is a necessary part

    of the default jbpm-console webapp deployment.





    The Identity components (User, Group, Membership) of jBPM are typically mapped via a

    so-called JDBC User Realm in Tomcat or  any other non-jBoss server, and the process 

    requires a specific Realm be created for any given server implementation.  The instructions

    relevant to Tomcat are

    available here.

    Deployment of the jbpm-console under  Jetty also requires a specific User Realm.





    Without access to the jBPM Identity components, one cannot access the

    jbpm-console to deploy jpdl service archives from the eclipse designer. One can implement one's

    own User Realm, but it is not fully compatible with default jbpm-console webapp until it

    contains the Sesame Street users and groups. This has led to

    long and complicated threads

    in the forum, which were resolved only after it was understood that the Identity

    database must exist to deploy jbpm-console under Tomcat.





    To that end, the Tomcat instructions linked above provide both sql scripts necessary

    to instantiate the database for MySQL - including the identity components.





    The question then, is - What if I want to deploy under Tomcat, but against some other database (not MySQL)?





    The answer is to let hibernate do the work of creating the database for you,

    instead of trying to run the SQL scripts.  How?





    Easy as one, two, three:




    1. Create the empty jBPM database in your database server





    Use any given means for doing this.  Make sure to create a database user for jbpm which has read/write

    permissions for the new database.







    2. Download and run the JUnit test below





    2.1 You'll need the standard libraries for jbpm including jbpm-identity, along with Junit.





    2.2 Install and compile and put the hibernate.cfg.xml and sesamestreet.xml

    in the classpath so that dbCreate can find them.





    2.3 The hibernate.cfg.xml attached below comes configured for PostgreSQL.  You'll need

    to re-configure the dialect and driver entries in the file appropriatly for your database type.

    Remember to install the drivers jarfile, as well.





    3. Run dbCreate and setup a JDBC Realm in $YOURSERVER





    3.1 Run as a Junit test.  Check that all 32 tables are created in your

    database, and that the JBPM_ID_USER table contains entries for ernie, bert, and the rest.





    3.2 Configure your JDBC UserRealm for the server.  Tomcat instructions are found

    at the link above. 





    Now you should be able to run jBPM default web app in Tomcat against any database which is supported by hibernate.