Why can't SessionBean's EJBObjects be Shared
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   udaya_das
Posted On:   Wednesday, October 7, 2009 02:31 PM

I am using 2.1 specs Based on Point 6.6 on specs....( On my first servlet I obtained the reference for the EJBObject I called the business method Stored the EJBObject reference in HttpSession Navigated to the next servlet Retrived the EJBObject reference from HttpSession Invoked business method again Happy to see that it works What if I store the reference in ServletContext instead of HttpSession.Can two users share the same EJBObject at the same point of time by getting the reference from ServletContext . Regards Udaya    More>>

I am using 2.1 specs


Based on Point 6.6 on specs....(




  • On my first servlet I obtained the reference for the EJBObject

  • I called the business method

  • Stored the EJBObject reference in HttpSession

  • Navigated to the next servlet

  • Retrived the EJBObject reference from HttpSession

  • Invoked business method again

  • Happy to see that it works


What if I store the reference in ServletContext instead of

HttpSession.Can two users share the same EJBObject at the same point of
time by getting the reference from ServletContext .



Regards


Udaya

   <<Less

Re: Why can't SessionBean's EJBObjects be Shared

Posted By:   Anonymous  
Posted On:   Thursday, October 22, 2009 02:56 AM

You must synchronize the calls made by several threads

(web clients using the servlet context) using the same EJBObject.

The EJBObject instance you receive after lookup or
injection is basically a stub. this stub might use I/O,
JTA and more to interact with the EJB container.
These types of interactivity requires synchronization -
so each client will get served in its own context.
About | Sitemap | Contact