0 Replies Latest reply on Jan 17, 2003 7:05 AM by Andrew May

    Accessing CMR in read-only method

    Andrew May Newbie

      I've been getting:
      java.lang.IllegalStateException: A CMR collection may only be used within the transction in which it was created
      when load testing an application.

      I have a pair of entity beans being accessed - Identity & IdentityProperties. There's a 1-M CMR between the two entities. Additional there's a helper method on the Identity that does this:

      public Map getPropertyMap()
      {
      Map result = new HashMap();
      Set properties = getIdentityProperties();
      for (Iterator i = properties.iterator(); i.hasNext(); )
      {
      IdentityPropertyLocal p = (IdentityPropertyLocal) i.next();
      result.put(p.getName(), p.getValue());
      }
      return result;
      }
      [ it's the i.hasNext() that throws the Exception ]

      This is part of a Web application where many sessions may share the same identity. Because reading in the identity can be a bottle neck, I have set all the get* methods to be read-only in the deployment descriptor:

      <method-attributes>

      <method-name>get*</method-name>
      <read-only>true</read-only>

      </method-attributes>

      The Entities are called from a Stateless Session bean that has all methods Transaction Required (and I've also tried setting Transaction Mandatory on the Entities).

      Everything works fine when using the site as a single user, but when I've been load testing, as the number of users goes up I start getting the CMR exception.

      I can only think of 2 possibilities; either the transaction is getting "lost" under load, or somehow seperate transactions are sharing the iterator. Neither is a comforting thought.

      Has anyone else had similar problems?

      I've been load testing without the read-only setting and I don't get the error - however there performance gets quite bad when I have > 200 users, and I suspect this is due to them reading from a shared identity and locking it for the duration of a transaction. So I would really like to be able to run this with the read-only setting.

      Any help would be greatly appreciated.

      Andrew