1 Reply Latest reply on Dec 4, 2001 3:14 AM by Vincent Harcq

    setEntityContext() called each time EJB accessed

    alphafoo Newbie

      I am using JBoss2.4 with BMP's using the EJB2.0 spec. My beans get created and I see the ejbCreate() methods called in my logs--- that all works fine. Each time I access a created bean, the container calls setEntityContext() on that bean. Interestingly, it does not call ejbActivate() again.

      I expected this setEntityContext() method to be called only once, when the bean was moved into the pooled state.

      Can someone tell me why it gets called so often?

        • 1. Re: setEntityContext() called each time EJB accessed
          Vincent Harcq Newbie

          I got the same impression, post this to jboss-dev.
          This is inline with the spec in fact.
          The problem is that JBoss (2.4.4) does not pool entity instances for reuse, so for every finder method a new entity is created and setEntityContext is run.
          I submit a patch today to jboss-dev, we'll see.
          If you do jndi lookup in setEntitContext you can avoid the overhead by using a ServiceLocator pattern : a singleton that holds home instances