I think its time you found a more reliable source for your practice questions.
I agree with (B) however I'd quibble with (A).
The
EJB 2.0 Spec states in "5.3 Local Clients"
Unlike the remote client view, the local client view of a bean is not location independent. Access to an enterprise bean through the local client view requires the collocation in the same JVM of both the local client and the enterprise bean that provides the local client view. The local client view therefore does not provide the location transparency provided by the remote client view.
Now the answer states: "A) Local Clients should be used when the web server is running on the same machine as the application server."
If the web server and the application server are separate applications they will most likely run in separate processes - how are they going to share a JVM?.
I simply don't know if the current generation of application servers run the web container in the same JVM as the EJB container - for the EJB container callbacks to work the web container would actually have to run inside the EJB container. Can
servlets use local EJB interfaces? I don't think so (I'm probably wrong, but where exactly in the J2EE specs is this guarantueed? - wait a minute the servlet spec does mention the <ejb-local-ref> element - so I was wrong) - though I wouldn't be surprised if there are some proprietary vendor extensions that would allow (remote) call optimization between a collocated servlet and EJB.
PS: Actually looking at (B) again - even that one is shaky
"Beans in the same Virtual Machine should use local Clients." TRUE."Local Clients should be used when Session Beans need to communicate with Entity Beans." Yes - if the Session bean is collocated with the entity bean. Otherwise you have to use a remote interface. So really this part is FALSE as it does not specify that the beans are collocated. Its anybody's guess if the second sentence is supposed to imply this. [ September 22, 2005: Message edited by: Peer Reynders ]