Hi,
I have a simple stateful session bean, which have several methods calling CMP beans and some direct database objects. My problem is the the transaction seems to be committed every invocation of the session bean. I think the transaction must be alive during the instance of session bean is alive but the situation is each transactions are provided for each invocation. The source codes and configuration is as follows:
1. the session bean
public class ProcessManagerBean implements javax.ejb.SessionBean, SessionSynchronization, ProcessManagerRemote{ //process initialization, execution public String initializeProcess(String processDefinition, String instanceName) throws RemoteException{...} public String initializeProcess(String processDefinition) throws RemoteException{...} public void executeProcess(String instanceId) throws RemoteException{...} public void executeProcessByWorkitem(String instanceId, ResultPayload resultPayload) throws RemoteException{....} .......... }
<container-transaction> <method> <ejb-name>ProcessManagerEJB</ejb-name> <method-name>*</method-name> </method> <trans-attribute>Required</trans-attribute> </container-transaction>
InitialContext context = new InitialContext(); ProcessManagerHomeRemote pmh = (ProcessManagerHomeRemote)context.lookup("ProcessManagerHomeRemote"); ProcessManagerRemote pm = pmh.create(); pid = pm.initializeProcess(pd); pm.executeProcess(pid); pm.remove();