LifeCycle of Stateless Session Bean


EJB programming & troubleshooting: LifeCycle of Stateless Session Bean

  1. LifeCycle of Stateless Session Bean (2 messages)

    Hi all,

    I have a small problem. I am using a pool of stateless session bean. When I use a pool of 20, the ejbcreate() method is being called 20 times, with no call to the setsessioncontext() method, when weblogic is started. However on client call (create()), the sessioncontext is null.

    Now, if i make the pool size to 0, in that case on a client call the(create()) the setsessioncontext() method and then the ejbcreate() methods are called in the sequence.

    As per my understanding, setsessioncontext() is called first and then ejbcreate() on a client call of create() on the homeinterface.

    This means that when pool size is 0, the behaviour is as expected. However on making the pool size>0, the behaviour is different, particularly that the sessioncontext is null, which seems to be strange. Can somebody explain what is happening and why?

    When does weblogic actually call setSessionContext() and when does it call ejbCreate(). Explanations in the light of the above behaviour would be highly appreciated.

  2. for whatever it is worth, Weblogic 5.1 (sp11) does not behave this way, it calls setSessionContext then ejbCreate for each bean created at startup for the initial pool.
  3. Hi ,

    Agreed what you are saying is true.But the problem we are facing is as below
    When there are no beans in the pool we are able to get the Context on making a client call. and thus the container is managing the transaction on occurence of Exception .As soon as we make pool size as 20 SessionContext is not getting set ..thus when a transaction fails ..container is not doing a rollback..Now to test this we put print command and found that setSessionContest is not called thus sc.setRollBack() is not happening and weblogic is throwing NullPointerException.
    If we dont put beans in pool at startup the same code works fine but it is hindering the performance..

    Any help would be appreciated