This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Websphere and the fly likes How to create multiple instances of session EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "How to create multiple instances of session EJB" Watch "How to create multiple instances of session EJB" New topic
Author

How to create multiple instances of session EJB

MichaelOConnor25
Greenhorn

Joined: May 30, 2002
Posts: 2
I am learning WSAD 4.0.3.
I have a stateless session EJB. I can run the test client in WSAD and use the JNDI lookup to call the create method and then access my EJB.
However when I invoke the create method again I do not get a second instance.
How can I get it to create a 2nd instance of my EJB?
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Ummm...Stateless beans are pooled. That's what stateless means. WHY would you want to create a second instance? What are you trying to do? It seems to me you're not quite clear on how session EJB's work...
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
MichaelOConnor25
Greenhorn

Joined: May 30, 2002
Posts: 2
Bascially, load balancing -
I'm trying to write a EJB which serves as an interface to a bank of CORBA servers.
The CORBA servers are instances of the same application running on different machines, each of which is single threaded. The calls are synchronous so the calling code gets blocked until the request finishes.
My idea was to have multiple instances of a session EJB. Each, when it is invoked, chooses the next CORBA server to invoke on.
Do you think this is wrong approach altogether and I should just have 1 multithreaded session EJB?
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
OK, the EJB is already multithreaded and load balanced if it's a stateless session EJB. So just try this:
Build a stateless EJB that on each call to the EJB RANDOMLY picks a server out of the list of CORBA servers and sends a request to it. That particular EJB thread will block on that CORBA call, yes, but that's OK -- the EJB is stateless, so the other threads in the thread pool will continue to run other "copies" of that method servicing other servers the whole time...
Kyle
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to create multiple instances of session EJB
 
Similar Threads
ejbCreate in session bean
How to access oracle in ejb
simple XA transaction (problem)
ejbCreate in session bean
EJB 2.0, WSAD 5, example problem