6 Replies Latest reply on Dec 14, 2001 12:21 PM by Michael Jara

    Concurrent access on EntityBean ejbLoad

    Lamouret Newbie

      Hi,

      With multiple clients of a same instance of an EntityBean, ejbLoad is invoking more than once during the same time. But ejbLoad inits all member variables so some clients get the init data instead of the real data when they invoke getXXX method... What can i do for not having init data when clients call getXXX method ?

      Can somebody help me ?

      Bruno

        • 1. Re: Concurrent access on EntityBean ejbLoad
          Dain Sundstrom Master

          What version of JBoss are you using? Are you using JAWS for the entity bean? What exactally are you seeing?

          -dain

          • 2. Re: Concurrent access on EntityBean ejbLoad
            Lamouret Newbie

            Hi,
            I'm using JBoss 2.2.2, with Postgresql 7.1
            I don't think using JAWS.
            I've Servlet calling SessionBean (Statefull), and this SessionBean calling EntityBeans. Transactions are controlled by the Container (Supports).
            When some clients connected to the application during the same time, Servlet are called, then one instance of the SessionBean are created for each client. Each SessionBean instance calls EntityBean.ejbFindXXX method. Then, I think only one EntityBean.ejbLoad should be executed, but there is more than one.
            So, for example :
            1. the SessionBean SB1 calls EntityBean.ejbFindXXX,
            2. the SessionBean SB2 calls EntityBean.ejbFindXXX,
            3. SB1 calls getXXX method of the EntityBean EB1
            4. EB1.ejbLoad is executed because of SB1 EntityBean.ejbFindXXX, initializes members variable, reads data into the persistent storage, and affects the member variable with the data from DB,
            5. EB1.ejbLoad is executed because of SB2 EntityBean.ejbFindXXX, initializes members variable,
            6. SB1.getXXX is executed, and SB1 gets initialize entityBean member variables,
            7. EB1.ejbLoad continuated, reads data into the persistent storage, and affects the member variables with the data from DB,
            8. SB2.getXXX is executed, and SB2 gets entityBean members variable, those from persistent storage.

            So, SB1 and SB2 have not the same values from the same instance of an EntityBean...


            Thanks for your help

            Bruno


            • 3. Re: Concurrent access on EntityBean ejbLoad
              Blazej Bulka Newbie

              I had similar problem with JBoss 2.4.1 and 2.4.3.
              However JBoss 2.4.0 and 2.4.4 does not seem to be affected. I also used "Required" or "RequiresNew" transaction setting to ensure that the bean executes in a transaction.

              I hope above helps

              Blazej

              • 4. Re: Concurrent access on EntityBean ejbLoad
                Oliver Henlich Newbie

                Hi guys, I think i'm getting the exact same problem but nobody has given me a response...do you wanna look through the following posting to confirm we are experiencing the same thing? I thought it was something to do with my configuration...but i guess not. It seems like a serious BUG....need to get someone from dev to confirm maybe.

                http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/

                • 5. Re: Concurrent access on EntityBean ejbLoad
                  Lamouret Newbie

                  Hi,
                  The method from my SessionBean has "NotSupported" attribute.
                  The method getXXX of my EntityBean has "Supports" attribute.
                  I can't used here "Required" or "RequiresNew" attributes, because if I have a lot of client, the Application Server is locked on "LOCKING-WAITING (TRANSACTION)"

                  Jarda, i don't know if you have the same problem. All i can tell you is that my Bean 's not been passivated... And my problem is only when there is concurrent access on the same EntityBean, on the same time. If 2 clients access on the same EntityBean, one à time t and second at time t+1min, then i've no problem, ejbLoad is called only once.

                  Bruno

                  • 6. Re: Concurrent access on EntityBean ejbLoad
                    Michael Jara Newbie

                    We have an app deployed in JBoss 2.2.2 that makes fairly heavy use of entity beans, and I have never seen such a problem. JBoss activates and passivates our entity beans like a champ, as can be seen from the debug logs. Can you duplicate this problem in a very short sample program? If so, I'd suggest posting it.

                    All I can suggest is what I did: 1. Implement the (JBoss proprietary) "isModified" method, so that JBoss doesn't attempt to "ejbStore" your bean when you were just trying to read it. 2. For read-only methods, set the transaction attribute to SUPPORTS or NOTSUPPORTED, and 3. For read/write methods, set the transaction attribute to REQUIRED (regardless of whether you think you need a transaction or not... There were apparantly problems in 2.2.2 trying to write to an entity bean w/o transaction.)

                    I have not tried to deploy our app in any later version of JBoss (except for 2.4 when it was in beta, which seemed to work.)

                    Good luck.
                    Mike