1 2 Previous Next 23 Replies Latest reply on Oct 2, 2006 5:30 AM by oyabun

    Exception: CMR field value is already loaded

    lfinis

      I running stress test and when i get to 20 users (+10 loops each) I'm starting to see this exception:
      2003-07-23 20:20:52,969 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException, causedBy:
      javax.ejb.EJBException: CMR field value is already loaded
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge$FieldState.loadRelations(JDBCCMRFieldBridge.java:1531)

      Did anybody have similar problem?

      Log is attached.

      Thanks,
      Leonid

        • 1. Re: Exception: CMR field value is already loaded

          JBoss version??

          -- Juha

          • 2. Re: Exception: CMR field value is already loaded
            jmhofer

            Hi,

            I get this too at a lot of places. Seems to be a lot better reproducible if multiple users access the server. I have absolutely no idea why it happens.

            JBoss version is 3.2.1. It's happening in CMT "Required", "read-only" stuff. I've tried setting locking to QueuedPessimistic and to NoLock, and to "Instance per Transaction", but to no avail.

            Please someone answer this. I see this is asked a lot. Either this is some common beginner mistake in handling CMR, or something is wrong. There has to be someone who can at least explain a bit what leads to this strange exception?

            • 3. Re: Exception: CMR field value is already loaded
              aloubyansky

              Please, try 3.2.3 at least and if it is not fixed then submit a bug report with code snippets demonstrating what you are doing with CMR and stacktraces. Thanks.

              • 4. Re: Exception: CMR field value is already loaded
                jmhofer

                We have updated jBoss to 3.2.3 and unfortunately we still get the same exception.
                It seems that only 1-N or N-M relations are affected. 1-1 seem to work without that problem.

                Our CMR method "Bundle.getItems" is defined with transaction attribute "Required" in the assembly descriptor and set to "read-only" via jboss.xml. It is called from within a stateful session bean.The calling method has also "Required" and is also set to read-only.

                Stacktrace:

                javax.ejb.EJBException: CMR field value is already loaded
                 at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge$FieldState.loadRelations(JDBCCMRFieldBridge.java:1531)
                 at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.load(JDBCCMRFieldBridge.java:1051)
                 at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.load(JDBCCMRFieldBridge.java:1037)
                 at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getInstanceValue(JDBCCMRFieldBridge.java:550)
                 at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getValue(JDBCCMRFieldBridge.java:508)
                 at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:124)
                 at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59)
                 at myPackage.BundleEJB$Proxy.getItems(<generated>)
                



                Relation Definition:

                <ejb-relation>
                 <ejb-relation-name>Bundle-Item</ejb-relation-name>
                
                 <ejb-relationship-role>
                 <multiplicity>One</multiplicity>
                 <relationship-role-source><ejb-name>BundleBean</ejb-name></relationship-role-source>
                 <cmr-field>
                 <cmr-field-name>items</cmr-field-name>
                 <cmr-field-type>java.util.Set</cmr-field-type>
                 </cmr-field>
                 </ejb-relationship-role>
                
                 <ejb-relationship-role>
                 <multiplicity>Many</multiplicity>
                 <relationship-role-source><ejb-name>ItemBean</ejb-name></relationship-role-source>
                 </ejb-relationship-role>
                </ejb-relation>
                



                • 5. Re: Exception: CMR field value is already loaded
                  aloubyansky

                  read-only in jboss.xml? Set it to false and try again.

                  • 6. Re: Exception: CMR field value is already loaded
                    jmhofer

                    Sadly, removing the read-only definitions has not changed anything concerning the exception.

                    • 7. Re: Exception: CMR field value is already loaded
                      aloubyansky

                      Do you access CMR in transaction?
                      Can you give me instructions to reproduce this?
                      Do you have a testcase?

                      • 8. Re: Exception: CMR field value is already loaded
                        jmhofer

                         

                        "loubyansky" wrote:
                        Do you access CMR in transaction?
                        Can you give me instructions to reproduce this?
                        Do you have a testcase?


                        Yes, we access CMR in a transaction. We are using container-managed transactions throughout our application. Also, it is not a web application; we access the server through RMI client applications.

                        I am sorry, but I can not provide you with easy instructions or even a testcase, as we are nearing our own release date for that product, and it is quite complex.

                        I can try to explain a little about the context which this problem happens in.

                        We have a ServerEntity entity bean, which has a 1-N-CMR-relation to a ServerItem bean. We want to send a value object ServerEntityVO for that ServerEntity Bean to the client. At first, we gave the constructor of the ServerEntityVO the ServerEntity instance and let it fill its own fields, especially by retrieving the related ServerItems and also creating value objects for them.

                        We had the impression that we could avoid the bug in some places by pre-querying the data necessary to build the value object and calling the VO constructor with this data as parameters, though we had no idea why that should work better (except probably some Java lazy instantiation scheme which would lead to the VO being created when already out of the server method transaction context?)

                        However, this "workaround" scheme did not always succeed. It's also not easy to determine how well it does because the CMR bug happens more in a sporadic than in a reproducible way. We are able to reproduce it somewhat consistently in our complex application by accessing it by two clients at once.

                        It would probably be quite time-consuming to try to factor out exactly the bug-producing code into a simple, reproducible testcase. And I fear that the "near-reproducibility" of the bug would rather disappear during that process...

                        • 9. Re: Exception: CMR field value is already loaded
                          cvandyck

                          I've just started getting this bug too.

                          javax.ejb.EJBException: CMR field value is already loaded
                          at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge$FieldState.loadRelations(JDBCCMRFieldBridge.java:1722
                          at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.load(JDBCCMRFieldBridge.java:1263)
                          at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.load(JDBCCMRFieldBridge.java:1252)
                          at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getInstanceValue(JDBCCMRFieldBridge.java:633)
                          at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getValue(JDBCCMRFieldBridge.java:589)
                          at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:119)
                          at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59)


                          It's only reproducible, though, under heavy load. The relationship is a 1-many CMR, and read-only and transactional context doesn't seem to affect it.

                          I can reproduce it by spawning five different simultaneous requests to the same SLSB method that (eventually) invokes the CMR.

                          JBoss will throw this exception, though, usually just on one of the threads. The other threads execute successfully. Further low-load invocations of the SLSB method do not produce this problem ever.

                          Any ideas?

                          I'm using JBoss 3.2.3.

                          Thank you.
                          Collin

                          • 10. Re: Exception: CMR field value is already loaded
                            aloubyansky

                            First, remove read-only for CMR. Could you describe this heavy load?

                            • 11. Re: Exception: CMR field value is already loaded
                              cvandyck

                              Well, our application essentially renders pages, which are constructed using many different kinds of entities, so a page render might involve 20-30 different entities.

                              I replicate it by bookmarking about 15 different page render URLs and then loading them all simultaneously.

                              I also see a

                              javax.management.RuntimeMBeanException: RuntimeException in MBean operat
                              ion 'invoke(org.jboss.invocation.Invocation)'

                              error from time to time.

                              I can catch these errors, though, and let my client (servlet) retry the render, which always works.

                              I try and run these renders outside of a transactional context because doing so results in a lot of deadlock.

                              thanks-

                              • 12. Re: Exception: CMR field value is already loaded
                                aloubyansky

                                I guess it's read-only CMR invocation causing this but still need to test it.

                                • 13. Re: Exception: CMR field value is already loaded
                                  dvines

                                  All-

                                  Please forgive if this gets posted twice. I tried submititng it earlier but it didn't seem to work.

                                  Anyway, we're gettinig the same error from a load test that we ran today. We get the exact same stack trace as Collin. We're using JBoss 3.2.2 on Linux and Sun VM 1.4.1. We're using CMP 2.0.

                                  Other backgorund:

                                  - The relationship and target entity uses on-find.
                                  - Its failing in an accessor for a 1-m relationship.
                                  - The accessor method is defined as read-only.
                                  - The transaction type is required.
                                  - The commit option is A.

                                  Any thoughts or suggestions would be appreciated.

                                  Thanks,

                                  -- Don

                                  • 14. Re: Exception: CMR field value is already loaded
                                    cvandyck

                                    Hey Guys

                                    Any updates on this issue?

                                    thanks,
                                    Collin

                                    1 2 Previous Next