JBoss Community

Re: JBPM5 - How can I change the database?

created by Ryan Peterson in jBPM - View the full discussion

I seem to have things working properly with mysql, I'll see if I can help (Running JBPM 5.1):

 

my Maven dependencies (this took a long time to find the correct versions that would work together, I borrowed heavily from some of the example projects):

    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
    </dependency>

 

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
    </dependency>

 

    <dependency>
        <groupId>org.jbpm</groupId>
        <artifactId>jbpm-flow</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jbpm</groupId>
        <artifactId>jbpm-bpmn2</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jbpm</groupId>
        <artifactId>jbpm-flow-builder</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jbpm</groupId>
        <artifactId>jbpm-persistence-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
    </dependency>

 

    <!-- Generic JPA Persistence -->
    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>persistence-api</artifactId>
    </dependency>

 

    <!-- Transaction Management -->
    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>jta</artifactId>
    </dependency>

 

    <dependency>
        <groupId>org.codehaus.btm</groupId>
        <artifactId>btm</artifactId>
    </dependency>

 

    <!-- Persistence Provider: Hibernate -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
    </dependency>

 

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-annotations</artifactId>
    </dependency>

 

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
    </dependency>

 

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
    </dependency>

 

    <!-- Data Base: H2-->
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>

 

    <!-- Logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
    </dependency>

 

    <!-- reporting -->
    <dependency>
        <groupId>org.jbpm</groupId>
        <artifactId>jbpm-bam</artifactId>
    </dependency>

 

 

My persistence.xml:

  <persistence-unit name="org.jbpm.persistence.jpa">

 

    <provider>org.hibernate.ejb.HibernatePersistence</provider>

    <jta-data-source>jdbc/processInstanceDS</jta-data-source>

    <class>org.drools.persistence.info.SessionInfo</class>

    <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>

    <class>org.jbpm.persistence.processinstance.ProcessInstanceEventInfo</class>

    <class>org.drools.persistence.info.WorkItemInfo</class>

    <class>org.jbpm.process.audit.ProcessInstanceLog</class>

    <class>org.jbpm.process.audit.NodeInstanceLog</class>

    <class>org.jbpm.process.audit.VariableInstanceLog</class>

 

    <properties>

      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>

      <property name="hibernate.max_fetch_depth" value="3"/>

      <property name="hibernate.hbm2ddl.auto" value="update"/>

      <property name="hibernate.show_sql" value="true"/>

      <property name="hibernate.transaction.manager_lookup_class"

                value="org.hibernate.transaction.BTMTransactionManagerLookup"/>

    </properties>

 

  </persistence-unit>

 

 

My unit test DB setup:

 

@BeforeTest
public void setup() {
    // setup a JNDI Datasource using Bitronix PoolingDataSource
    ds = new PoolingDataSource();
    ds.setUniqueName( "jdbc/processInstanceDS" );
    ds.setClassName("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");

 

    ds.setMinPoolSize(0);
    ds.setMaxPoolSize(3);
    ds.setAllowLocalTransactions(true);
    ds.getDriverProperties().put("user", "userName");
    ds.getDriverProperties().put( "password", "userPassword" );
    ds.getDriverProperties().put( "URL", "jdbc:mysql://localhost:3306/jbpm" );
//    ds.getDriverProperties().put( "URL", "jdbc:h2:mem:mydb" );  // in-memory DB

 

    ds.init();
}

Reply to this message by going to Community

Start a new discussion in jBPM at Community