Reference blog: http://blog.csdn.net/dcl8261425/article/details/6575797
First install jbpm5 and MySQL ....
1. modify configuration files related to jbpm persistence
1. jbpm-installer/DB/hibernate. cfg. xml
The remarks section is the configuration of the original H2 database, the same below.
2. jbpm-installer/DB/persistence. xml
JTA-data-source that matches the JNDI-name in the testDS1-ds.xml, self-modified
<persistence-unit name="org.drools.persistence.jpa" transaction-type="JTA"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:jdbc/jbpmDatasource</jta-data-source> <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class> <class>org.drools.persistence.info.SessionInfo</class> <class>org.drools.persistence.info.WorkItemInfo</class><!-- <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/> <property name="hibernate.max_fetch_depth" value="3"/> <property name="hibernate.hbm2ddl.auto" value="create" /> <property name="hibernate.show_sql" value="false" /> <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" /> </properties> --> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/jbpm?useUnicode=true&characterEncoding=UTF-8" /> <property name="hibernate.connection.username" value="root"/> <property name="hibernate.connection.password" value="root"/> <property name="hibernate.connection.autocommit" value="true" /> <property name="hibernate.max_fetch_depth" value="3"/> <property name="hibernate.hbm2ddl.auto" value="create" /> <property name="hibernate.show_sql" value="false" /> </properties> </persistence-unit>
3. jbpm-installer/DB/testDS1-ds.xml
<datasources><!-- <local-tx-datasource> <jndi-name>jdbc/testDS1</jndi-name> <connection-url>jdbc:h2:tcp://localhost/~/test</connection-url> --><!--connection-url>jdbc:h2:mem:mydb</connection-url--><!-- <driver-class>org.h2.jdbcx.JdbcDataSource</driver-class> <user-name>sa</user-name> <password></password> </local-tx-datasource>--> <jndi-name>jdbc/jbpmDatasource</jndi-name> <connection-url>jdbc:mysql://localhost:3306/jbpm?useUnicode=true&characterEncoding=UTF-8</connection-url> <!--connection-url>jdbc:h2:mem:mydb</connection-url--> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>root</user-name> <password>root</password></datasources>
4. jbpm-installer/runtime/jbpm-bam.jar/hibernate. cfg. xml
5. jbpm-installer/runtime/jbpm-human-task-{version}. Jar/persistence. xml
<properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/jbpm?useUnicode=true&characterEncoding=UTF-8" /> <property name="hibernate.connection.username" value="root"/> <property name="hibernate.connection.password" value="root"/> <property name="hibernate.connection.autocommit" value="true" /> <property name="hibernate.max_fetch_depth" value="3"/> <property name="hibernate.hbm2ddl.auto" value="create" /> <property name="hibernate.show_sql" value="false" /> </properties>
Ii. Related jar packages
MySQL driver package is placed in jbpm-installer/DB/driver
Download slf4j related packages, http://www.slf4j.org/download.html
Download btm-1.3.2.jar
3. Compile taskserver. Java
Need to import jar package: btm-1.3.2.jar, slf4j-jdk14-1.6.2.jar, MySQL driver package
You just need to replace the marked items with your own ones.
Public static final void main (string [] ARGs) {try {poolingdatasource ds1 = new poolingdatasource (); ds1.setuniquename ("JDBC/jbpmdatasource"); // here ds1.setclassname ("com. mySQL. JDBC. jdbc2.optional. mysqlxadatasource "); ds1.setmaxpoolsize (3); ds1.setallowlocaltransactions (true); // ds1.getdriverproperties () related to the following database (). put ("user", "root"); ds1.getdriverproperties (). put ("password", "root"); ds1.ge Tdriverproperties (). Put ("url", "JDBC: mysql: // localhost: 3306/jbpm? Useunicode = true & characterencoding = UTF-8 "); ds1.init (); entitymanagerfactory emftask = persistence. createentitymanagerfactory ("org. jbpm. task "); taskservice = new taskservice (emftask, systemeventlistenerfactory. getsystemeventlistener ();/** Add the required users */taskservicesession tasksession = taskservice. createsession (); tasksession. adduser (new user ("Administrator"); tasksession. adduser (new user ("krisv"); tasksession. adduser (new user ("John"); tasksession. adduser (new user ("Mary");/* Start Mina server for HT */minataskserver Server = new minataskserver (taskservice); thread = new thread (server); thread. start (); system. out. println ("server started... ");} catch (throwable t) {T. printstacktrace ();}}
All right, start taskserver and run evaluation in the sample to finish the tasks in the human task. If there is no error, everything will be OK.