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.