1 Reply Latest reply on Dec 26, 2007 8:08 AM by Johan Parent

    reconfigure hobernate.connection.password for jbpm connectio

    Tammy Croteau Newbie

      I am using jbpm 3.2 and mysql.

      I need to remove the hibernate.connection.password from the hibernate.cfg.xml file as it is considered a security breach to have the password in plain text.

      However, once the hibernate sessionfactory is built in jbpm I am no longer able to change the password property and have jbpm pick up the value and use it. I have also tried just setting the System property and this also is not working.

      Is there a way to do this in my code?

        • 1. Re: reconfigure hobernate.connection.password for jbpm conne
          Johan Parent Newbie


          I don't know if that's the best way to do this but here is how I did it (just last week in fact).

          NOTE: I did this for jbpm3.1 but things may not have changed that much for 3.2.

          You need to do 2 things:

          1) make your own DbPersistenceServiceFactory
          2) patch your jbpm.cfg.xml

          Some snippets below (adjust to your package names etc):

          In 1 you do the runtime (re)configuration of your credentials. Below I use my own code to get the credentials from somewhere else.

          public class MyDbPersistenceServiceFactory extends org.jbpm.persistence.db.DbPersistenceServiceFactory {
           private static final long serialVersionUID = 1L;
           public synchronized Configuration getConfiguration() {
           Configuration config = super.getConfiguration();
           config.setProperty("hibernate.connection.username", Credentials.getUsername());
           config.setProperty("hibernate.connection.password", Credentials.getPassword());
           return config;

          And now 2 tell jbpm to use your factory by making your jbpm.cfg.xml look like this (more or less):

           <!--<service name="persistence" factory="org.jbpm.persistence.db.DbPersistenceServiceFactory" />-->
           <service name="persistence">
           <bean class="MyDbPersistenceServiceFactory"/>

          Hope this helps,