5 Replies Latest reply on Nov 19, 2001 5:48 AM by Marcus Brito

    ejbLoad not being invoked on created BMP

    Erik Sliman Apprentice

      I discovered when running one of Sun's tutorials that BMPs created with ejbCreate() never get their ejbLoad invoked, even when you call methods where transaction is set to required from the client.

      In contrast, objects where instantiated with findByPrimaryKey() that were never created with an EJB work just find, with ejbLoad() being invoked. However, if you do a findByPrimaryKey() on an object that you recently created with ejbCreate(), it gets a reference to the same object, and fails to ever call ejbLoad().

      Is this a bug in JBoss? Does anyone have a solution?


      Erik Sliman

        • 1. Re: ejbLoad not being invoked on created BMP
          David Jencks Master

          Jboss's default Commit Option is A which assumes that jboss is the only app modifying the data, so it never needs to check the db after it gets one copy of the data... from create or find.

          If you want to be able to change the db with other apps, investigate commit options B or C which will reload data for each transaction.

          • 2. Re: ejbLoad not being invoked on created BMP
            Erik Sliman Apprentice

            This is not an issue of another app using the database, but simply a problem because ejbLoad was used to load child data from another bean, and this child data was never getting loaded. I could not load it in ejbCreate because it was too early, the child data did not exist yet. The same client uses other beans to create it, then goes back to the parent to get its child data in the form of an Array.

            I will however try the commit option to see if that works out the problem. I just wanted to note that in this case it was simply other EJBs accessing related data, not another instance of JBoss or any other client.

            • 3. Re: ejbLoad not being invoked on created BMP
              Navdeep Newbie

              I was having a similar problem. But the reason I figured out this was happening is because I was calling the BMP bean from a session bean and my transaction attributes in ejb-jar were not correct.
              The reason I was having problem is that the method in the session bean seems to start a transaction of its own, even though I have not specified any transaction attribute for the session bean. The default transaction level in JBoss seems to be required and not supports. So if you set you session bean methods to be "Supports" and entity bean methods to "Required".
              It seems to work for me.
              But I am not 100% sure on this.

              • 4. Re: ejbLoad not being invoked on created BMP
                Luc Tran Hiep Newbie

                hi all,

                I have faced the same problem. When I choose the commit option C, the container dot not invoke ejbLoad() when I remove and re-create a bean with the same primary key. So the data of the new bean is the same with data of the old bean. I think this is a bug of Jboss version 2.2+ . Because the version 2.0 Final does not bring about this problem.

                • 5. Re: ejbLoad not being invoked on created BMP
                  Marcus Brito Novice

                  Perhaps you should load your child date in ejbPostCreate(). This is the true purpose of this method. (And you _may_ call ejbLoad() in ejbPostCreate(), I think).