Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Stateless Session Bean Create() method  RSS feed

 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a doubt about a Stateless Session Bean ejb Create method. It was mentioned in the Head First EJB that clients calls create() method and bean instance creation are completely different & Unrelated time.

But when tested with weblogic server, I found that following:

1. Client gets the ejb Home stub Object.
2. On calling the create method on Home, clients get remote stub object.(EJBObject is created here as per Head First EJB BOOK).
3. The missing point is even after some time, class.newInstance(), setSessionContext() and ejbCreate() methods were not invoked.

4. But when I call the business methods, the above methods are called in the first business method call!!!.


In Head First EJB it was mentioned that, after the home create method and before the business method call , in an unrelated time the bean instances are created and pooled, but here only after the first business method invocation the bean instances are created. Also I found that in the bean pool have only one instance for the business method invocation. Is it not possible that initially we can create 10 beans in the pool like connection pool?

(I am using weblogic 7.0 trial version)

Thanks & Regards,
M.S.Raman
 
Natarajan Shankar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raman,
In HFB, said as for Stateless Bean

1. while server starting it-self it will create the pool of stateless bean object
2. Then while calling create(), it will create a EJBObject - Remote Interface (NOT Implementation class ie., not bean object) stub and pass it to the client.
3. While calling first business method the EJBObject will be coupled with the Bean (Bean class object).

So as per your testing, till point-2 things we're ok. Then it after calling first busioness method all object creation, setSessionContext().. are called later.

Hope this might give a hint for your testing.
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Natarajan Shankar:

while server starting it-self it will create the pool of stateless bean object


Hi Natarajan,

Even I have assumed that while after successful bean deployment or server startup the Bean instances are created and pooled. But it is not happening in that way in weblogic server.

<B>HelloWorldBean class </B>

public HelloWorld()
{
System.out.println("Inside the HelloWorld Bean constructor");
}

public void setSessionContext(SessionContext ctx)
{
System.out.println("Session Context method is called");
}

public void ejbCreate()
{
System.out.println("EJB Create Method is called");
}

public void sayHello()
{
System.out.println("HelloWorld");
}

Only during the first Business method call (sayHello), I am getting the following output:

Inside the HelloWorld Bean constructor
Session Context method is called
EJB Create Method is called

--> Why I am not getting the above output after server startup or Bean deployment?

HelloWorld

After the calling the same business method I am getting the following only output (Correct)

HelloWorld

Regards,
M.S.Raman
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No beans are created on startup unless you make an entry like this in the WebLogic DD:

<initial-beans-in-free-pool>10</initial-beans-in-free-pool>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!