Meaningless Drivel is fun!
The moose likes EJB and other Java EE Technologies and the fly likes EJb and incoming requests Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJb and incoming requests" Watch "EJb and incoming requests" New topic

EJb and incoming requests

Amer Seifeddine
Ranch Hand

Joined: Apr 25, 2002
Posts: 57
Hello All,

I know that EJB is using the multithreading feature to manage EJB sessions and manage the lifecycle.. That is well understood. What I need to know:

which thread is used to fetch records from the database? If EJB thread is the answer, then what the jsp thread will be doing at this time? waiting/sleeping ?

In Other words, when an incoming request (including rmi) is initiated, which container's thread is executing the code in the ejb session (including the datastore fetch/update or delete).. Thanks!
Mark McMillan

Joined: May 16, 2008
Posts: 5
It probably depends on the implementation of the server. Your code should not make any assumptions.

In WebSphere if the WAR and EJBs are deployed in the same server, then the JSP thread will call directly into the EJB container and it will run the EJB code there. However, if the WAR is deployed in a separate server (e.g. in the web tier) then of course the JSP's thread cannot be used (it does not exist in the EJB server). In that case the EJB is run with a container thread and the JSP thread is blocked (waiting) in the RMI call.

Other vendors (e.g. WebLogic) may behave differently when both containers are in the same JVM. When they are separate JVMs, the same thread cannot be used no matter the vendor.
I agree. Here's the link:
subject: EJb and incoming requests
It's not a secret anymore!