Shobhit Tyagi
2013-03-14 17:51:02 UTC
Shobhit Tyagi [https://community.jboss.org/people/roxy1987] created the discussion
"Transaction Issue with EJBs"
To view the discussion, visit: https://community.jboss.org/message/802749#802749
--------------------------------------------------------------
Hi Community,
I have run into an issue with transactions.
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.
I have 3 separate prjects. One web, one EJB and one simple java.
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.
In my SessionBean, I use the TransactionManagement annotation as
@TransactionManagement(TransactionManagementType.BEAN)
And I call the BPM APIs as
@Resource
private EJBContext context;
Â
....
....
@Override
public void completeTask(long taskID, String userID, Map<String, Object> map) throws Exception
{
 UserTransaction ut = context.getUserTransaction();
 try
 {
  ut.begin();
  BpmAPI.startTask(taskID, userID);
  BpmAPI.completeTask(taskID, userID);
  ut.commit();
 }
 catch(Exception e)
 {
  ut.rollback();
  e.printStackTrace();
 }
}
Â
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.
If I dispose the taskHandler, the transaction exception goes away but the process instance still doesnt proceed after completing the task.
I believe for signalling the process, taskHandler needs to be not disposed.
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.
COuld anyone please help me with the Transaction Management.
I use Websphere 8.5 web container.
Regards.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/802749#802749]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
"Transaction Issue with EJBs"
To view the discussion, visit: https://community.jboss.org/message/802749#802749
--------------------------------------------------------------
Hi Community,
I have run into an issue with transactions.
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.
I have 3 separate prjects. One web, one EJB and one simple java.
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.
In my SessionBean, I use the TransactionManagement annotation as
@TransactionManagement(TransactionManagementType.BEAN)
And I call the BPM APIs as
@Resource
private EJBContext context;
Â
....
....
@Override
public void completeTask(long taskID, String userID, Map<String, Object> map) throws Exception
{
 UserTransaction ut = context.getUserTransaction();
 try
 {
  ut.begin();
  BpmAPI.startTask(taskID, userID);
  BpmAPI.completeTask(taskID, userID);
  ut.commit();
 }
 catch(Exception e)
 {
  ut.rollback();
  e.printStackTrace();
 }
}
Â
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.
If I dispose the taskHandler, the transaction exception goes away but the process instance still doesnt proceed after completing the task.
I believe for signalling the process, taskHandler needs to be not disposed.
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.
COuld anyone please help me with the Transaction Management.
I use Websphere 8.5 web container.
Regards.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/802749#802749]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]