<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Human tasks : LocalTaskService JTA issue
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/milhaim">Miloud Haimoune</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/743349#743349">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi all,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I'm Using JBPM5.2.final in a seam 2 application all running under jboss 5.1 SA.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>When a use LocalTaskService as following : </p><p>to connect the service : </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>public</b></font> <font color="navy"><b>void</b></font> connect() <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>if</b></font> (service == <font color="navy"><b>null</b></font>) <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; org.jbpm.task.service.TaskService taskService = HumanTaskService.getService();&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; service = <font color="navy"><b>new</b></font> LocalTaskService(taskService.createSession());
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
....
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>and I register the human task :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; TaskService taskService = HumanTaskService.getService();&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; SyncWSHumanTaskHandler handler = <font color="navy"><b>new</b></font> SyncWSHumanTaskHandler(<font color="navy"><b>new</b></font> LocalTaskService(taskService.createSession()), ksession);&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ksession.getWorkItemManager().registerWorkItemHandler(<font color="red">"Human Task"</font>, handler);
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>But when a start my process instance and create a human task I get then the following exception (<strong>A JTA EntityManager cannot use getTransaction()</strong>) : </p><p>I'm using jboss transaction manager</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">12:33:59,014 ERROR [STDERR] Caused by: java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
12:33:59,014 ERROR [STDERR]&#160;&#160;&#160;&#160; at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:324)
12:33:59,014 ERROR [STDERR]&#160;&#160;&#160;&#160; at org.jbpm.task.service.TaskServiceSession.taskOperation(TaskServiceSession.java:442)
12:33:59,014 ERROR [STDERR]&#160;&#160;&#160;&#160; at org.jbpm.task.service.local.LocalTaskService.start(LocalTaskService.java:224)
12:33:59,014 ERROR [STDERR]&#160;&#160;&#160;&#160; at com.atriumnetwork.jbpm.LocalTaskManager.completeTask(LocalTaskManager.java:96)
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I checked in the sources ther were tow options for TransactionType: default and local-JTA</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So I tried to set the transaction type to local-JTA :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">taskSession.setTransactionType(<font color="red">"local-JTA"</font>);
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This is working when I start my process&#160; but&#160; when&#160; execution other human tasks I get : <strong>No active JTA transaction on joinTransaction call exception</strong></p><p><strong><br/></strong></p><pre class="jive-pre"><code class="jive-code jive-java">Caused by: java.lang.RuntimeException: javax.persistence.TransactionRequiredException: No active JTA transaction on joinTransaction call
&#160;&#160;&#160; at org.jbpm.task.service.TaskServiceSession.doOperationInTransaction(TaskServiceSession.java:990)
&#160;&#160;&#160; at org.jbpm.task.service.TaskServiceSession.taskOperation(TaskServiceSession.java:433)
&#160;&#160;&#160; at org.jbpm.task.service.local.LocalTaskService.skip(LocalTaskService.java:220)
&#160;&#160;&#160; at org.jbpm.process.workitem.wsht.SyncWSHumanTaskHandler.abortWorkItem(SyncWSHumanTaskHandler.java:256)
&#160;&#160;&#160; at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.internalAbortWorkItem(JPAWorkItemManager.java:76)
&#160;&#160;&#160; at org.jbpm.workflow.instance.node.WorkItemNodeInstance.cancel(WorkItemNodeInstance.java:249)
&#160;&#160;&#160; at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.setState(WorkflowProcessInstanceImpl.java:257)
&#160;&#160;&#160; at org.jbpm.workflow.instance.node.EndNodeInstance.internalTrigger(EndNodeInstance.java:57)
&#160;&#160;&#160; at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>is there another option for the transaction type ??&#160; </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>any help will be very appreciated</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/743349#743349">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>