JBpm 4.3 + Spring 3 transaction problem at buildProcessEngine
tom42332 Jan 28, 2010 10:26 AMWhen starting up JBPM using Configuration.buildProcessEngine() I get an exception
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)
I put a breakpoint at CheckDbCmd at that line and found out that there is an underlying exception:
org.hibernate.HibernateException: createQuery is not valid without active transaction
However transactions are definitely enabled (Spring transactions, see stacktrace below). I've also tried a multitude of variations of configuring transaction management in jbpm, such as <hibernate-session current="true" /> and changing current to false and lots of other variations.
I somehow have the impression it could be related to Tom Baeyens observations.
Has anyone any idea how to solve this?
Using JBPM 4.3, Spring 3.0.0, Hibernate 3.3.1, MSSQL Server.
jbpm.cfg.xml:
<?xml version="1.0" encoding="UTF-8"?> <jbpm-configuration spring="enabled"> <import resource="jbpm.jobexecutor.cfg.xml" /> <import resource="jbpm.jpdl.cfg.xml"/> <import resource="jbpm.bpmn.cfg.xml" /> <process-engine-context> <repository-service /> <repository-cache /> <execution-service /> <history-service /> <management-service /> <identity-service /> <task-service /> <string name="spring.cfg" value="jbpm/jbpm-spring-config.xml" /> <types resource="jbpm.variable.types.xml" /> <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator"> <field name="commandService"><ref object="newTxRequiredCommandService" /></field> </object> <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" /> <command-service name="txRequiredCommandService"> <skip-interceptor /> <retry-interceptor /> <environment-interceptor /> <spring-transaction-interceptor /> </command-service> <command-service name="newTxRequiredCommandService"> <retry-interceptor /> <environment-interceptor policy="requiresNew" /> <spring-transaction-interceptor policy="requiresNew" /> </command-service> </process-engine-context> <transaction-context> <repository-session /> <db-session /> <message-session /> <timer-session /> <identity-session /> <history-sessions> <object class="org.jbpm.pvm.internal.history.HistorySessionImpl" /> </history-sessions> <transaction type="spring" /> <hibernate-session current="true" />
.
jbpm/spring application context:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <import resource="../properties-config.xml"/> <bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper"> <property name="jbpmCfg" value="jbpm/jbpm.cfg.xml"/> </bean> <bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" /> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> <property name="dataSource" ref="dataSource" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:/jbpm/jbpm.hibernate.cfg.xml" /> <property name="dataSource" ref="dataSource" /> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource"> <property name="driverClass" value="net.sourceforge.jtds.jdbc.Driver" /> <property name="url" value="jdbc:jtds:sqlserver://${Database.server}:${Database.port}/${Database.database}" /> <property name="username" value="${Database.user}" /> <property name="password" value="${Database.password}" /> </bean> </beans>
.
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.SQLServerDialect</property> <property name="hibernate.current_session_context_class">thread</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>