问题描述:我的jbpm4.4例子在一台电脑上运行是好的。mysql是5.6版本,配置文件jbpm.hibernate.cfg.xml的方言是
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
。但是复制到另外一台电脑执行的时候就报错了。这台电脑的mysql是5.5版本,没有修改配置文件就包了如下的错误。
14:49:32,188 FIN | [WireContext] eagerly initializing org.jbpm.pvm.internal.id.DatabaseIdComposer
14:49:32,226 INF | [Environment] Hibernate 3.3.1.GA
14:49:32,234 INF | [Environment] hibernate.properties not found
1
14:49:35,593 INF | [SchemaUpdate] schema update complete
14:49:36,078 FIN | [HibernateSessionResource] ----- beginning hibernate tx 1471948789 --------------------------------------------------------
14:49:36,101 FIN | [SQL]
select
propertyim0_.KEY_ as KEY1_2_,
propertyim0_.VERSION_ as VERSION2_2_,
propertyim0_.VALUE_ as VALUE3_2_
from
JBPM4_PROPERTY propertyim0_ limit ?
14:49:36,128 WRN | [JDBCExceptionReporter] SQL Error: 1146, SQLState: 42S02
14:49:36,128 SEV | [JDBCExceptionReporter] Table 'test.jbpm4_property' doesn't exist
14:49:36,137 FIN | [SQL]
select
executioni0_.DBID_ as DBID1_3_,
executioni0_.DBVERSION_ as DBVERSION3_3_,
executioni0_.ACTIVITYNAME_ as ACTIVITY4_3_,
executioni0_.PROCDEFID_ as PROCDEFID5_3_,
executioni0_.HASVARS_ as HASVARS6_3_,
executioni0_.NAME_ as NAME7_3_,
executioni0_.SUPEREXEC_ as SUPEREXEC16_3_,
executioni0_.SUBPROCINST_ as SUBPROC17_3_
from
JBPM4_EXECUTION executioni0_ limit ?
14:49:36,141 WRN | [JDBCExceptionReporter] SQL Error: 1146, SQLState: 42S02
14:49:36,142 SEV | [JDBCExceptionReporter] Table 'test.jbpm4_execution' doesn't exist
### EXCEPTION ###########################################
14:49:36,143 INF | [DefaultCommandService] exception while executing command org.jbpm.pvm.internal.cmd.CheckDbCmd@60f00693
org.jbpm.api.JbpmException: no jBPM DB schema: no JBPM4_EXECUTION table. Run the create.jbpm.schema target first in the install tool.
at org.jbpm.pvm.internal.cmd.CheckDbCmd.execute(CheckDbCmd.java:50)
at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:50)
at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:56)
at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
at org.jbpm.pvm.internal.processengine.ProcessEngineImpl.checkDb(ProcessEngineImpl.java:152)
at org.jbpm.pvm.internal.processengine.ProcessEngineImpl.<init>(ProcessEngineImpl.java:105)
at org.jbpm.pvm.internal.cfg.ConfigurationImpl.instantiateProcessEngine(ConfigurationImpl.java:100)
at org.jbpm.pvm.internal.cfg.ConfigurationImpl.buildProcessEngine(ConfigurationImpl.java:92)
at org.jbpm.api.Configuration.getProcessEngine(Configuration.java:126)
at com.tgb.video.testJbpm.deploy(testJbpm.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
75)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
### EXCEPTION ###########################################
14:49:36,144 FIN | [HibernateSessionResource] ----- rolling back hibernate tx 76659128 -----------------------------------------------------
解决办法:修改配置文件jbpm.hibernate.cfg.xml的方言为:
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
就好了。
下面是jbpm.hibernate.cfg.xml的配置文件:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> -->
<!-- <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- <property name="hibernate.connection.url">jdbc:hsqldb:mem:.</property> -->
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.format_sql">true</property>
<mapping resource="jbpm.repository.hbm.xml" />
<mapping resource="jbpm.execution.hbm.xml" />
<mapping resource="jbpm.history.hbm.xml" />
<mapping resource="jbpm.task.hbm.xml" />
<mapping resource="jbpm.identity.hbm.xml" />
</session-factory>
</hibernate-configuration>