最近公司叫搞JBPM5分析出数据库结构。但是新东西。我英文又不好。所以就瞎琢磨。
最后main方法可以运行。数据库可以更改。但是把jar包部署tomcat或jboss成为web项目时。却总是报错。
现在总结一下过程。发出来记录一下。有会弄得高手给指导一下。
首先下载:http://www.jboss.org/jbpm 5.0final全部程序
简单安装demo:
cmd命令行下:
ant install.demo (需要联网)
当完成后
ant start.demo(所有程序启动完毕即可)
http://localhost:8080/jbpm-console jbpm web控制台
http://localhost:8080/drools-guvnor 流程管理(可在线设计流程)
整合到已有环境:
修改build.properties
# the home of your JBoss AS installation
# for example:
# jboss.server.version=5.1.0.GA
# jboss.home=./jboss-${jboss.server.version}
jboss.server.version=4.2.3.GA(版本)
jboss.home=D:/jboss-4.2.3.GA(自己的路径)
# defines which server configuration should be used
# for example, if you specify 'default', the application
# will be deployed to ${jboss.home}/server/default/deploy
jboss.server.configuration=default
# the home of your eclipse installation
# will be used to deploy the Eclipse plugin to
eclipse.home=E:/8.5eclipse(自己的路径)
# defines whether you want the birt plugin (for reporting) to be downloaded or not
# by default this is turned off to avoid having to do a rather large download
# if you do not download the birt plugin, reporting in the jbpm-console will not work
# put this property to true if you want to download birt as well
jBPM.birt.download=true
然后可以执行:
ant install.guvnor.into.jboss
ant install.designer.into.jboss
ant install.jBPM-gwt-console.into.jboss
ant install.jBPM-eclipse.into.eclipse(最好手动以连接方式)
ant install.drools-eclipse.into.eclipse(最好手动以连接方式)
myeclipse手动连接方式:
目录:/8.5eclipse/dropins
3个link文件:
插件所在目录:jbpm-5.0.0-installer-full/jbpm-installer/lib
jbpm5.link(jbpm-5.0.0-eclipse-all.zip)
gef.link(GEF-ALL-3.5.2.zip 没有的话另行下载)
drool.link(drools-5.2.0.M1-eclipse-all.zip)
内容:
path=E://8.5eclipse//eclipse(插件相对应的路径)
然后可以启动:
Startup database:
ant start.h2
Startup JBoss AS:
ant start.jboss
Startup task service:
ant start.human.task
转移数据库:
目录:jbpm-5.0.0-installer-full/jbpm-installer/db
persistence.xml
hibernate.cfg.xml
testDS1-ds.xml
修改这些文件,方言之类的都要改
目录:jbpm-5.0.0-installer-full/jbpm-installer/db/driver
放入数据库驱动
程序方面:
持久化方面:
需要用到的jar包:
org.apache.servicemix.bundles.commons-dbcp-1.2.2_3.jar
commons-pool-1.4.jar
subethasmtp-wiser-1.2.jar
slf4j-nop-1.5.8.jar
mysql.jar (or other driver)
btm-1.3.jar
还有jbpm runtime 的所有jar包
需要把runtime的jbpm-human-task-5.0.0.jar和jbpm-bam-5.0.0.jar内的有关数据库连接的配置文件全部修改成myeclips
非web运行时:
需要手工程序中创建数据源:
PoolingDataSource ds=new PoolingDataSource();
ds.setUniqueName("jdbc/testDS1");
ds.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");
ds.setClassName("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");
//ds.setClassName("org.apache.commons.dbcp.BasicDataSource");
ds.setMaxPoolSize(3);
ds.setAllowLocalTransactions(true);
//ds.getDriverProperties().setProperty("driverClassName", "com.mysql.jdbc.Driver");
ds.getDriverProperties().put("user","root");
ds.getDriverProperties().put("password", "dcl1300185");
ds.getDriverProperties().put("URL", "jdbc:mysql://localhost/test");
ds.init();
知识库,session的创建,process的执行:
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn"), ResourceType.BPMN2);
KnowledgeBase kbase = kbuilder.newKnowledgeBase();
//StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
///KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
// start a new process instance
//ksession.startProcess("com.sample.bpmn.hello");
//logger.close();
EntityManagerFactory emf=Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
env.set( EnvironmentName.TRANSACTION_MANAGER,
TransactionManagerServices.getTransactionManager() );
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession( kbase,null, env );
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WSHumanTaskHandler());
ksession.startProcess("com.sample.bpmn.hello");
persistence.xml文件的编写:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence version="1.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="org.jbpm.persistence.jpa" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/testDS1</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.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>
</persistence>
jndi.properties 文件内容:
java.naming.factory.initial=bitronix.tm.jndi.BitronixInitialContextFactory
log4j.properties 文件:
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct messages to file hibernate.log ###
#log4j.appender.file=org.apache.log4j.FileAppender
#log4j.appender.file.File=hibernate.log
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=warn, stdout
#log4j.logger.org.hibernate=info
#log4j.logger.org.hibernate=debug
### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug
### log just the SQL
#log4j.logger.org.hibernate.SQL=debug
### log JDBC bind parameters ###
#log4j.logger.org.hibernate.type=info
#log4j.logger.org.hibernate.type=debug
### log schema export/update ###
#log4j.logger.org.hibernate.tool.hbm2ddl=debug
### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug
### log cache activity ###
#log4j.logger.org.hibernate.cache=debug
### log transaction activity
#log4j.logger.org.hibernate.transaction=debug
### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug
### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace
放置目录:
jndi.properties
log4j.properties
放置:src/main/resources
persistence.xml
放置:src/main/resources/META-INF(没有则自行创建)
www.haida360.com