4 Replies Latest reply on Apr 17, 2003 12:22 PM by Andreas Ronge

    Using CMR collection with commit A does not work ?

    Andreas Ronge Newbie


      I get the following error message
      "java.lang.IllegalStateException: The iterator of a CMR collection may only be used within the transction in which it was created"
      when using an iterator of a CMR collection in a CMP entity bean.
      This bean is only called from a stateless sessionbean with the required tx attribute an all methods.
      The collection/iterator is only used inside the entity bean.
      I suspect that the container use the same iterator when the session bean
      is called by two concurrent clients.
      However, commit option B does work.

      Is this a bug that is related to Bug item #575815, or I'm a doing something wrong ?
      (https://sourceforge.net/tracker/?func=detail&atid=376685&aid=575815&group_id=22866)

      I'm using jboss-3.0.4_tomcat-4.0.6, jdk1.4.1_02
      The CMP entity bean function that throws the exception:
      private void doesNotWork() {
      Collection c = getACmrCollection();
      Iterator iter = c.iterator();
      while (iter.hasNext()) { // throws an Exception
      ...
      }
      }
      Stack trace:
      java.lang.IllegalStateException: The iterator of a CMR collection may only be used within the transction in which it was created
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet$1.verifyIteratorIsValid(RelationSet.java:309)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.RelationSet$1.hasNext(RelationSet.java:269)
      at se.mcs.configuration.entitybean.ejb.ConfigurationBean.getHashtableFromPropertiesCollection(Unknown Source)
      at se.mcs.configuration.entitybean.ejb.ConfigurationBean.getConfigurationValue(Unknown Source)
      at sun.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1194)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:95)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:297)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:90)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:163)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:107)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
      at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
      at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invoke(BaseLocalContainerInvoker.java:301)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
      ...

      Regards
      Andreas

        • 1. Re: Using CMR collection with commit A does not work ?
          Dave Esmond Newbie

          Are you using any of the jboss special read-only designators on these methods? JBoss read-only allows multiple threads to access the CMR which results in the potential for one thread to invalidate the iterator's Set reference.

          The patch was added to 3.2 but we're trying to see if we can have it back-ported to earlier version(s).

          http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java.diff?r1=1.43.2.16&r2=1.43.2.17&only_with_tag=Branch_3_2

          • 2. Re: Using CMR collection with commit A does not work ?
            Dave Esmond Newbie

            Are you using any of the jboss special read-only designators on these methods? JBoss read-only allows multiple threads to access the CMR which results in the potential for one thread to invalidate the iterator's Set reference.

            The patch was added to 3.2 but we're trying to see if we can have it back-ported to earlier version(s).

            http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java.diff?r1=1.43.2.16&r2=1.43.2.17&only_with_tag=Branch_3_2

            • 3. Re: Using CMR collection with commit A does not work ?
              Hemang Newbie

              Hi,

              If you have <container-transaction> tag in your ejb-jar.xml.Comment it and try.


              • 4. Re: Using CMR collection with commit A does not work ?
                Andreas Ronge Newbie

                No, I'm not using read-only on these methods.
                We are actually using commit D but I think I verified that the same problem also occurs for commit A.
                We are going to try to upgrade to JBoss 3.2 and see if the problem disappears.
                Here is the container configuration:

                <container-configuration>
                <container-name>Standard CMP 2.x EntityBean</container-name>
                <sync-on-commit-only>false</sync-on-commit-only>
                <call-logging>false</call-logging>
                <container-invoker>org.jboss.proxy.ejb.ProxyFactory</container-invoker>
                <container-interceptors>
                org.jboss.ejb.plugins.LogInterceptor
                org.jboss.ejb.plugins.SecurityInterceptor
                org.jboss.ejb.plugins.TxInterceptorCMT
                org.jboss.ejb.plugins.MetricsInterceptor
                org.jboss.ejb.plugins.EntityCreationInterceptor
                org.jboss.ejb.plugins.EntityLockInterceptor
                org.jboss.ejb.plugins.EntityInstanceInterceptor
                org.jboss.ejb.plugins.EntityReentranceInterceptor
                org.jboss.resource.connectionmanager.CachedConnectionInterceptor
                org.jboss.ejb.plugins.EntitySynchronizationInterceptor
                org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor
                </container-interceptors>
                <client-interceptors>

                org.jboss.proxy.ejb.HomeInterceptor
                org.jboss.proxy.SecurityInterceptor
                org.jboss.proxy.TransactionInterceptor
                org.jboss.invocation.InvokerInterceptor


                org.jboss.proxy.ejb.EntityInterceptor
                org.jboss.proxy.SecurityInterceptor
                org.jboss.proxy.TransactionInterceptor
                org.jboss.invocation.InvokerInterceptor

                <list-entity>
                org.jboss.proxy.ejb.ListEntityInterceptor
                org.jboss.proxy.SecurityInterceptor
                org.jboss.proxy.TransactionInterceptor
                org.jboss.invocation.InvokerInterceptor
                </list-entity>
                </client-interceptors>
                <instance-pool>org.jboss.ejb.plugins.EntityInstancePool</instance-pool>
                <instance-cache>org.jboss.ejb.plugins.EntityInstanceCache</instance-cache>
                <persistence-manager>org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager</persistence-manager>
                <transaction-manager>org.jboss.tm.TxManager</transaction-manager>
                <locking-policy>org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock</locking-policy>
                <container-cache-conf>
                <cache-policy>org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy</cache-policy>
                <cache-policy-conf>
                <min-capacity>50</min-capacity>
                <max-capacity>1000000</max-capacity>
                <overager-period>300</overager-period>
                <max-bean-age>600</max-bean-age>
                <resizer-period>400</resizer-period>
                <max-cache-miss-period>60</max-cache-miss-period>
                <min-cache-miss-period>1</min-cache-miss-period>
                <cache-load-factor>0.75</cache-load-factor>
                </cache-policy-conf>
                </container-cache-conf>
                <container-pool-conf>
                100
                </container-pool-conf>
                <commit-option>D</commit-option>
                </container-configuration>