That’s correct. The current WSHT
implementation (Drools Task) uses JPA entity manager to get hold of transaction
which will not work if the transaction-type configured as JTA.
http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html#getTransaction()
Cheers
Vijay
From:
rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Todd Pagni
Sent: Wednesday, January 20, 2010
10:55 AM
To: rules-users@lists.jboss.org
Subject: [rules-users] Task Server
gives error cannot use getTransaction()
When
I configure the Task Server(org.drools.task) to be JTA I
get the following error when adding a Human Task work item. Is the
following Persistence Unit configuration valid? It works when the org.drools.task trans
type is set to LOCAL_RESOURCE.
Using
drools 5.1.0.M1 in JBoss 5.1
<?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.drools.persistence.jpa"
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/processInstanceDS</jta-data-source>
<mapping-file>META-INF/orm.xml</mapping-file>
<class>org.drools.persistence.session.SessionInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.processinstance.WorkItemInfo</class>
<class>org.drools.persistence.processinstance.variabletypes.JPAPersistedVariable</class>
<class>org.drools.persistence.processinstance.variabletypes.VariableInstanceInfo</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.SQLServerDialect"
/>
<property name="hibernate.max_fetch_depth"
value="3" />
<property name="hibernate.show_sql"
value="true" />
<property name="hibernate.hbm2ddl.auto"
value="update" />
<property name="hibernate.connection.release_mode"
value="auto" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup"
/>
<property name="jboss.entity.manager.factory.jndi.name"
value="java:/WorkflowServerPU"
/>
</properties>
</persistence-unit>
<persistence-unit
name="org.drools.task"
transaction-type=" RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/processInstanceDS</jta-data-source>
<mapping-file>META-INF/taskorm.xml</mapping-file>
<class>org.drools.task.Attachment</class>
<class>org.drools.task.Content</class>
<class>org.drools.task.BooleanExpression</class>
<class>org.drools.task.Comment</class>
<class>org.drools.task.Deadline</class>
<class>org.drools.task.Comment</class>
<class>org.drools.task.Deadline</class>
<class>org.drools.task.Delegation</class>
<class>org.drools.task.Escalation</class>
<class>org.drools.task.Group</class>
<class>org.drools.task.I18NText</class>
<class>org.drools.task.Notification</class>
<class>org.drools.task.EmailNotification</class>
<class>org.drools.task.EmailNotificationHeader</class>
<class>org.drools.task.PeopleAssignments</class>
<class>org.drools.task.Reassignment</class>
<class>org.drools.task.Status</class>
<class>org.drools.task.Task</class>
<class>org.drools.task.TaskData</class>
<class>org.drools.task.SubTasksStrategy</class>
<class>org.drools.task.OnParentAbortAllSubTasksEndStrategy</class>
<class>org.drools.task.OnAllSubTasksEndParentEndStrategy</class>
<class>org.drools.task.User</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.SQLServerDialect"
/>
<property name="hibernate.max_fetch_depth"
value="3" />
<property name="hibernate.show_sql"
value="true" />
<property name="hibernate.hbm2ddl.auto"
value="update" />
<property name="hibernate.connection.release_mode"
value="auto" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup"
/>
<property name="jboss.entity.manager.factory.jndi.name"
value="java:/WorkflowServerPU"
/>
</properties>
</persistence-unit>
</persistence>
10:48:22,887 INFO [STDOUT] Hibernate: update WorkItemInfo
set creationDate=?, name=?, processInstanceId=?, state=?, OPTLOCK=?, workItemByteArray=?
where workItemId=? and OPTLOCK=?
10:48:22,887 INFO [STDOUT] [2010:01:20 10:01:887:debug]
Message receieved on server : AddTaskRequest
10:48:22,887 INFO [STDOUT] [2010:01:20 10:01:887:debug]
Arguments : [org.drools.task.Task@537c3c9e, org.drools.task.service.ContentData@b2a90]
10:48:22,887 INFO [STDOUT] [2010:01:20 10:01:887:exception]
A JTA EntityManager cannot use getTransaction()
10:48:22,887 INFO [STDOUT] java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
10:48:22,887 INFO [STDOUT] at
org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:324)
10:48:22,887 INFO [STDOUT] at
org.drools.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:676)
10:48:22,887 INFO [STDOUT] at
org.drools.task.service.TaskServiceSession.addTask(TaskServiceSession.java:118)
10:48:22,887 INFO [STDOUT] at
org.drools.task.service.TaskServerHandler.messageReceived(TaskServerHandler.java:88)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:752)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:379)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:173)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
10:48:22,887 INFO [STDOUT] at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.filter.logging.LoggingFilter.messageReceived(LoggingFilter.java:95)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$HeadFilter.messageReceived(DefaultIoFilterChain.java:616)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:408)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:578)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:540)
10:48:22,887 INFO [STDOUT] at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:532)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:58)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.core.polling.AbstractPollingIoProcessor$Worker.run(AbstractPollingIoProcessor.java:857)
10:48:22,887 INFO [STDOUT] at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
10:48:22,887 INFO [STDOUT] at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
10:48:22,887 INFO [STDOUT] at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
10:48:22,887 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
10:48:22,887 ERROR [STDERR] java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
10:48:22,887 ERROR [STDERR] at
org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:324)
10:48:22,887 ERROR [STDERR] at
org.drools.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:676)
10:48:22,887 ERROR [STDERR] at
org.drools.task.service.TaskServiceSession.addTask(TaskServiceSession.java:118)
10:48:22,887 ERROR [STDERR] at
org.drools.task.service.TaskServerHandler.messageReceived(TaskServerHandler.java:88)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:752)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:379)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:173)
10:48:22,887 ERROR [STDERR] at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.filter.logging.LoggingFilter.messageReceived(LoggingFilter.java:95)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain$HeadFilter.messageReceived(DefaultIoFilterChain.java:616)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:408)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:578)
10:48:22,887 ERROR [STDERR] at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:540)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:532)
10:48:22,887 ERROR [STDERR] at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:58)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.core.polling.AbstractPollingIoProcessor$Worker.run(AbstractPollingIoProcessor.java:857)
10:48:22,887 ERROR [STDERR] at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
10:48:22,887 ERROR [STDERR] at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
10:48:22,887 ERROR [STDERR] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
10:48:22,887 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
10:48:22,903 INFO [LoggingFilter] SENT: HeapBuffer[pos=0
lim=2200 cap=4096: 00 00 08 94 AC ED 00 05 73 72 01 00 1F 6F 72 67...]
10:48:22,903 INFO [LoggingFilter] SENT: HeapBuffer[pos=0
lim=0 cap=0: empty]
10:48:22,903 INFO [STDOUT] [2010:01:20 10:01:903:debug]
Message receieved on client : AddTaskResponse
10:48:22,903
INFO [STDOUT] [2010:01:20 10:01:903:debug] Arguments : [java.lang.IllegalStateExcep