根據(jù)公司工作需要,這個元旦開始才選定用jBPM工作流引擎,什么東西都是一片空白,而jBPM的example WebSale程序是選用的技術(shù)卻是jsf, hibernate,一時無所適從。
            沒辦法只好硬著頭皮啃下去,jsf,hibernate
            這兩天都快抓狂了!!!無論如何都不能使用自己創(chuàng)建的mysql數(shù)據(jù)庫
            就快放棄的時候,老天終于眷顧我啦!!!


             根據(jù)一些前人的blog和工作流群上的人的指點,現(xiàn)總結(jié)以下兩種配置用mysql數(shù)據(jù)庫datasource的方法。

          (一)需要改jBPM源碼(這個方法不太好,但是可以讀讀源碼,了解機(jī)制)

          配置連接 MySQL

          1. jbpm-3.0\lib目錄下 創(chuàng)建mysql目錄

          2. mysql數(shù)據(jù)庫驅(qū)動 (mysql-connector-java-3.1.7-bin.jar) copymysql 目錄

          3. mysql 中創(chuàng)建一個數(shù)據(jù)庫,數(shù)據(jù)庫名字

          4. jbpm-3.0\src\resources目錄下創(chuàng)建mysql目錄

          5. 把兩個配置文件 (create.db.hibernate.properties, identity.db.xml) hsqldb目錄下 拷貝到mysql目錄
          create.db.hibernate.properties文件中內(nèi)容參考如下:

          # 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下創(chuàng)建mysql目錄,放進(jìn)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.aygfsteel.com/znjqolf/archive/2005/12/19/24654.html
          還有好多,查過之后都忘了鏈接了,謝謝前人的總結(jié)!



          方法二:
          1,在starter-kit server中部署的jbpm應(yīng)用里的deploy目錄中創(chuàng)建mysql-ds.xml

          文件內(nèi)容參考如下:
          <?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,刪除該目錄有關(guān)hsqldb  設(shè)置datasource的兩個xml文件。

          3,edit 上一目錄conf下的standardjaws.xml中的這段
          <datasource>java:/DefaultDS</datasource>
             <type-mapping>mySQL</type-mapping>
          讓type-mapping對應(yīng)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文件,更新該文件里面的數(shù)據(jù)庫配置


          參考文章:
          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 閱讀(985) 評論(2)  編輯  收藏 所屬分類: 工作流之jBPM
          Comments
          • # re: jBPM之WebSale換用MySQL DataSource
            ppxiaofei
            Posted @ 2006-10-09 09:00
            你好,我想請教一個問題,
            我現(xiàn)在的jbpm后臺使用oracle數(shù)據(jù)庫已經(jīng)成功了,現(xiàn)在部署自己的流程也已經(jīng)成功,但是調(diào)用自己寫的action時,提示沒有找到,我不知道怎么部署自己的action到服務(wù)器上,請問你做過這樣的工作嗎?謝謝了  回復(fù)  更多評論   
          • # re: jBPM之WebSale換用MySQL DataSource
            fantasyginge
            Posted @ 2006-10-09 11:36
            是不是你的服務(wù)器上沒有你的action class文件,或者放置位置有誤?

            關(guān)于action的配置,jbpm starter's kit的tutorial有詳細(xì)介紹。

            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了  回復(fù)  更多評論   

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
           
          主站蜘蛛池模板: 大连市| 永嘉县| 桃园市| 临邑县| 普兰县| 嵊泗县| 永兴县| 海林市| 河池市| 舞阳县| 泸水县| 堆龙德庆县| 射洪县| 织金县| 怀来县| 左云县| 鄂伦春自治旗| 桐城市| 政和县| 手机| 青河县| 南漳县| 西平县| 定兴县| 名山县| 六安市| 佛坪县| 淮南市| 甘肃省| 四平市| 陵川县| 三门峡市| 平罗县| 长垣县| 武山县| 图片| 南宫市| 兴安盟| 南京市| 绥芬河市| 金溪县|