1 Reply Latest reply on Oct 30, 2002 11:54 AM by justin

    CMR collection iteration (is wrapped in tx)

    justin Newbie

      I'm getting a similar error to several previous posts
      (e.g., "A CMR collection may only be used within the transction in which it was created", http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ )

      when attempting to iterate through a CMR Collection in a SLSB method. I believe I have set up the proper transaction attributes for the methods in this bean, however:

      <assembly-descriptor>
      <container-transaction>

      <ejb-name>CSRequestViewerBean</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>

      (the entity beans that this session bean uses are also set to 'Required' in
      their ejb-jar.xml files)

      here is the snippet of code from a method in this bean:
      public Collection getCSRsByJob(String jobId) throws RemoteException {
      try {
      LocalJob ljob = lookupJobHome().findByPrimaryKey(jobId);
      Collection c = ljob.getCSRequests();
      Collection result = new Vector();
      Iterator i = c.iterator(); //** THIS FAILS **
      for(; i.hasNext();) {
      LocalCSRequest csr = (LocalCSRequest)i.next();
      CSRViewObject vo = createCSRViewFromEntity(csr);
      result.add(vo);
      }
      return result;
      }
      (etc)

      From what I've found so far, basically every answer is to make sure the iterating method is wrapped in a user transaction or a session bean. This method definitely falls into the latter category, but I still get the error. Any hints are greatly appreciated!

      Jboss ver = 3.0.4RC1 (built from branch_3_0 on 10-28-2002)
      using Commit Option A
      I found a reference to bug # 575815
      https://sourceforge.net/tracker/?func=detail&atid=376685&aid=575815&group_id=22866

      but it appears to have been fixed over a month ago. Is there a chance it may
      still be a problem?

      Justin