根据公司工作需要,这个元旦开始才选定用jBPM工作流引擎,什么东西都是一片空白,而jBPM的example WebSale程序是选用的技术却是jsf, hibernate,一时无所适从。
  没办法只好硬着头皮啃下去,jsf,hibernate
  这两天都快抓狂了!!!无论如何都不能使用自己创建的mysql数据库
  就快放弃的时候,老天终于眷顾我啦!!!


   根据一些前人的blog和工作流群上的人的指点,现总结以下两种配置用mysql数据库datasource的方法。

(一)需要改jBPM源码(这个方法不太好,但是可以读读源码,了解机制)

配置连接 MySQL

1. jbpm-3.0\lib目录下 创建mysql目录

2. mysql数据库驱动 (mysql-connector-java-3.1.7-bin.jar) copymysql 目录

3. mysql 中创建一个数据库,数据库名字

4. jbpm-3.0\src\resources目录下创建mysql目录

5. 把两个配置文件 (create.db.hibernate.properties, identity.db.xml) hsqldb目录下 拷贝到mysql目录
create.db.hibernate.properties文件中内容参考如下:

# these properties are used by the build script to create
# a hypersonic database in the build/db directory that contains
# the jbpm tables and a process deployed in there

hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost:3306/jbpm
hibernate.connection.username=jbpm
hibernate.connection.password=jbpm
hibernate.c3p0.min_size=1
hibernate.c3p0.max_size=3
hibernate.show_sql=true

6. 在jbpm\lib下创建mysql目录,放进mysql的jdbc  driver

7.修改build.deploy.xml  文件中create.db task

<target name="create.db" depends="declare.jbpm.tasks, db.clean" description="creates a hypersonic database with the jbpm tables and loads the processes in there">
     <jbpmschema actions="create" properties="${basedir}/src/resources/mysql/create.db.hibernate.properties"/>
     <loadidentities file="${basedir}/src/resources/mysql/identity.db.xml" properties="${basedir}/src/resources/mysql/create.db.hibernate.properties"/>
     <ant antfile="build.xml" target="build.processes" inheritall="false" />
     <deploypar properties="${basedir}/src/resources/mysql/create.db.hibernate.properties">
       <fileset dir="build" includes="*.par" />
     </deploypar>
   </target>



 因为 Hibernate 不能将它的SessionFactorytomcatjndi 绑定 , 我们直接在源码中修改

9. 打开源文件 JbpmSessionFactory.java, getInstance() 方法里, 删除下面代码

InitialContext initialContext = new InitialContext();
 Object o = initialContext.lookup(jndiName);

将下面这行

instance = (JbpmSessionFactory)
PortableRemoteObject.narrow(o, JbpmSessionFactory.class);

替换为 instance = (JbpmSessionFactory)
PortableRemoteObject.narrow(
new JbpmSessionFactory(createConfiguration()), JbpmSessionFactory.class);

10. createConfiguration(String configResource) 方法里, 注释掉这段代码

String hibernatePropertiesResource =
JbpmConfiguration.getString("jbpm.hibernate.properties");

if (hibernatePropertiesResource!=null)
{
   Properties hibernateProperties = new Properties();

   try
      { 
         hibernateProperties.load(
                 ClassLoaderUtil.getStream(hibernatePropertiesResource) ); 
      }
   catch (IOException e)
     {
         e.printStackTrace();
         throw new RuntimeException(
               "couldn't load the hibernate properties" +
               " from resource '"hibernatePropertiesResource"'", e);
      }
    log.debug("overriding hibernate properties with "+ hibernateProperties); configuration.setProperties(hibernateProperties); 
 }

同时加入下面的代码

configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect"); configuration.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver"); configuration.setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/";); configuration.setProperty("hibernate.connection.username", "");

configuration.setProperty("hibernate.connection.password", "");

configuration.setProperty("hibernate.connection.pool_size", "15");

11.这种方法需要先开starter-kit中的jboss,然后build websale,最后deploy

参考文章:
http://mdvjiangbin.bokee.com/3185679.html
http://www.blogjava.net/znjqolf/archive/2005/12/19/24654.html
还有好多,查过之后都忘了链接了,谢谢前人的总结!



方法二:
1,在starter-kit server中部署的jbpm应用里的deploy目录中创建mysql-ds.xml

文件内容参考如下:
<?xml version="1.0" encoding="UTF-8"?>

<!-- The Hypersonic embedded database JCA connection factory config
$Id: hsqldb-ds.xml,v 1.15 2004/09/15 14:37:40 loubyansky Exp $ -->

<datasource>
   <local-tx-datasource>

      <!-- The jndi name of the DataSource, it is prefixed with java:/ -->
      <!-- Datasources are not available outside the virtual machine -->
      <jndi-name>DefaultDS</jndi-name>

      <!-- for tcp connection, allowing other processes to use the hsqldb
      database. This requires the org.jboss.jdbc.HypersonicDatabase mbean.
      <connection-url>jdbc:hsqldb:hsql://localhost:1701</connection-url>
-->
      <!-- for totally in-memory db, not saved when jboss stops.
      The org.jboss.jdbc.HypersonicDatabase mbean necessary
      <connection-url>jdbc:hsqldb:.</connection-url>
-->
      <!-- for in-process persistent db, saved when jboss stops. The
      org.jboss.jdbc.HypersonicDatabase mbean is necessary for properly db shutdown
-->
      <connection-url>jdbc:mysql://localhost:3306/jbpm</connection-url>

      <!-- The driver class -->
      <driver-class>com.mysql.jdbc.Driver</driver-class>

      <!-- The login and password -->
      <user-name>jbpm</user-name>
      <password>jbpm</password>

      <!--example of how to specify class that determines if exception means connection should be destroyed-->
      <!--exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.DummyExceptionSorter</exception-sorter-class-name-->

      <!-- this will be run before a managed connection is removed from the pool for use by a client-->
      <!--<check-valid-connection-sql>select * from something</check-valid-connection-sql> -->

      <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
      <min-pool-size>5</min-pool-size>

      <!-- The maximum connections in a pool/sub-pool -->
      <max-pool-size>20</max-pool-size>

      <!-- The time before an unused connection is destroyed -->
      <!-- NOTE: This is the check period. It will be destroyed somewhere between 1x and 2x this timeout after last use -->
      <!-- TEMPORARY FIX! - Disable idle connection removal, HSQLDB has a problem with not reaping threads on closed connections -->
      <idle-timeout-minutes>0</idle-timeout-minutes>
  
   </local-tx-datasource>
        <metadata>
  <type-mapping>mySQL</type-mapping>
  </metadata>
 </datasource>


2,删除该目录有关hsqldb  设置datasource的两个xml文件。

3,edit 上一目录conf下的standardjaws.xml中的这段
<datasource>java:/DefaultDS</datasource>
   <type-mapping>mySQL</type-mapping>
让type-mapping对应mysql-ds.xml中的type-mapping

Step 4: JMS configuration descriptors
a) Remove hsqldb-jdbc2-service.xml from folder deploy/jms. Save this file somewhere else.

b) Copy mysql-jdbc2-service.xml from folder docs/example/jms to deploy/jms.

c) Edit mysql-jdbc2-service.xml and change the datasource name if applicable. In my configuration I don't use HSQL at all so I configured the default datasource DefaultDS for MySQL. In this file, change mySQLDS to DefaultDS. Note that datasource names are case sensitive.

Step 5: Install MySQL Java Connector
Download MySQL Connector/J and place the file mysql-connector-java-3.0.15-ga-bin.jar in the lib folder of the server.



!!!同时需要修改deploy中jbpm.sar文件夹里的jbpm.sar.cfg.jar文件,更新该文件里面的数据库配置


参考文章:
http://wiki.jboss.org/wiki/Wiki.jsp?page=SetUpAMysqlDatasource
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3861605

posted on 2006-01-11 19:07 fantasyginge 阅读(970) 评论(2)  编辑  收藏 所属分类: 工作流之jBPM
Comments
  • # re: jBPM之WebSale换用MySQL DataSource
    ppxiaofei
    Posted @ 2006-10-09 09:00
    你好,我想请教一个问题,
    我现在的jbpm后台使用oracle数据库已经成功了,现在部署自己的流程也已经成功,但是调用自己写的action时,提示没有找到,我不知道怎么部署自己的action到服务器上,请问你做过这样的工作吗?谢谢了  回复  更多评论   
  • # re: jBPM之WebSale换用MySQL DataSource
    fantasyginge
    Posted @ 2006-10-09 11:36
    是不是你的服务器上没有你的action class文件,或者放置位置有误?

    关于action的配置,jbpm starter's kit的tutorial有详细介绍。

    3. Tutorial
    3.1. Hello World example
    3.2. Database example
    3.3. Context example: process variables
    3.4. Task assignment example
    3.5. Custom action example


    看那个Custom action example就ok了  回复  更多评论   

只有注册用户登录后才能发表评论。


网站导航: