<!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;">
    Transaction Issue with EJBs
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/roxy1987">Shobhit Tyagi</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/802749#802749">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 Community,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I have run into an issue with transactions.</p><p>I raised a similar question before and I marked it as answered after getting some helpful replies but it looks like the issue was temporarily gone.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I have 3 separate prjects. One web, one EJB and one simple java.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>For instance if I have to start a process or I have to complete a task, I send request from a Managed Bean(web project) to the Session Bean(EJB project), which calls the APIs present in the java project.</p><p>In my SessionBean, I use the TransactionManagement annotation as</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">@TransactionManagement(TransactionManagementType.BEAN)
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>And I call the BPM APIs as </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">@Resource
 <font color="navy"><b>private</b></font> EJBContext context;
&#160;
....
.... 
 
 @Override
 <font color="navy"><b>public</b></font> <font color="navy"><b>void</b></font> completeTask(<font color="navy"><b>long</b></font> taskID, String userID, Map&lt;String, Object&gt; map) <font color="navy"><b>throws</b></font> Exception
 <font color="navy">{</font>
&#160; UserTransaction ut = context.getUserTransaction();
&#160; <font color="navy"><b>try</b></font>
&#160; <font color="navy">{</font>
&#160;&#160; ut.begin();
&#160;&#160; BpmAPI.startTask(taskID, userID);
&#160;&#160; BpmAPI.completeTask(taskID, userID);
&#160;&#160; ut.commit();
&#160; <font color="navy">}</font>
&#160; <font color="navy"><b>catch</b></font>(Exception e)
&#160; <font color="navy">{</font>
&#160;&#160; ut.rollback();
&#160;&#160; e.printStackTrace();
&#160; <font color="navy">}</font>
 <font color="navy">}</font>
&#160;
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>But doing this gives me the transaction exception. It completes the task but doesnt signal the process instance. But this happens when I leave the taskHandler open, which is created while starting the process instance.</p><p>If I dispose the taskHandler, the transaction exception goes away but the process instance still doesnt proceed after completing the task. </p><p>I believe for signalling the process, taskHandler needs to be not disposed.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>For now the workaround I am doing is disposing the taskHandler, completing the task, completing the workitem(to signal process instance). But just completeTask should do the trick.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>COuld anyone please help me with the Transaction Management.</p><p>I use Websphere 8.5 web container.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Regards.</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/802749#802749">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>