Dominique Paquin [
http://community.jboss.org/people/paqman] created the discussion
"jBPM with SQL Server"
To view the discussion, visit:
http://community.jboss.org/message/627487#627487
--------------------------------------------------------------
Hello all,
I have been working on trying to integrate jBPM in out current product we are
developping. I have been successful in running hte in-memory version of the project but I
now need to store my process states in a data base for later recovery.
I'm using SQL Server 2005
My problem is in seting up the connection. I was able to setup a connection simply using
our javax.persistence.EntityManagerFactory (which has a
org.apache.commons.dbcp.BasicDataSource in it) and giving it as argument like this (with a
JTA transaction manager):
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, this.dataEntityManagerFactory);
env.set(EnvironmentName.TRANSACTION_MANAGER, new JtaTransactionManager());
and later calling
JPAKnowledgeService.newStatefulKnowledgeSession(knowledgeBase, null, env);
But when I start a process, I have a crash due to a missing TransactionManager.
...
Caused by: org.springframework.transaction.CannotCreateTransactionException: No JTA
UserTransaction available - programmatic PlatformTransactionManager.getTransaction usage
not supported
at
org.springframework.transaction.jta.JtaTransactionManager.doGetTransaction(JtaTransactionManager.java:770)
at
org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:335)
at
org.drools.container.spring.beans.persistence.DroolsSpringTransactionManager.begin(DroolsSpringTransactionManager.java:49)
at
org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:120)
... 65 more
So I tried to feed it the transaction manager we have already existing in our product,
org.springframework.transaction.PlatformTransactionManager,
env.set(EnvironmentName.TRANSACTION_MANAGER, platformTransactionManager);
but the code craches a bit further with:
2011-09-20 09:12:52,409 [525023568@qtp-1417375004-4] [ERROR]
[org.drools.persistence.SingleSessionCommandService] - Could not commit session
java.lang.NullPointerException
at
org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:125)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:116)
at
org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:54)
at
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:122)
...
...
...
Caused by: java.lang.NullPointerException
at
org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:125)
... 65 more
This is the persistence.xml file I use:
<?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
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
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
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
xmlns:orm="
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"
xmlns="
http://java.sun.com/xml/ns/persistence
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/processInstanceDS</jta-data-source -->
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.SQLServerDialect"/>
<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>
I obviously can't post my code since this is part of a huge project but if you have
specific questions, I can answer them. Help would be appreciated, be it with comments on
what I posted above or a Dummy's guide on how to run jBPM with SQL Server :)
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/627487#627487]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]