0 Replies Latest reply on May 3, 2006 6:44 PM by pongsor

    Transaction Demarcation on Stateful session beans

    pongsor Newbie

      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 method invocation. The source codes and configuration is as follows:

      1. the session bean

      
      public class ProcessManagerBean implements javax.ejb.SessionBean, SessionSynchronization, ProcessMan
      agerRemote{
       //process initialization, execution
       public String initializeProcess(String processDefinition, String instanceName) throws RemoteExcepti
      on{...}
       public String initializeProcess(String processDefinition) throws RemoteException{...}
      
       public void executeProcess(String instanceId) throws RemoteException{...}
       public void executeProcessByWorkitem(String instanceId, ResultPayload resultPayload) throws RemoteE
      xception{....}
       ..........
      }
      
      



      2. ejb-jar.xml
      
       <session>
       <ejb-name>ProcessManagerEJB</ejb-name>
       <home>org.uengine.processmanager.ProcessManagerHomeRemote</home>
       <remote>org.uengine.processmanager.ProcessManagerRemote</remote>
       <ejb-class>org.uengine.processmanager.ProcessManagerBean</ejb-class>
       <session-type>Stateful</session-type>
       <transaction-type>Container</transaction-type>
       </session>
      
       <container-transaction>
       <method>
       <ejb-name>ProcessManagerEJB</ejb-name>
       <method-name>*</method-name>
       </method>
       <trans-attribute>Required</trans-attribute>
       </container-transaction>
      




      3. client JSP
      
       InitialContext context = new InitialContext();
       ProcessManagerHomeRemote pmh = (ProcessManagerHomeRemote)context.lookup("ProcessManagerHomeRemote");
      
       ProcessManagerRemote pm = pmh.create();
      
       pid = pm.initializeProcess(pd);
       pm.executeProcess(pid);
       pm.remove();
      




      Also, when I have tried "UserTransaction", the transaction persisted properly. but finally the TransactionManager failed to commit because the client JSP have already committed the transaction. Exception "No Transaction" have occurred.

      Did I have mistake any of configuration? How do I solve this problem...