Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

About setSessionContext

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can some one explain why in setSessionContext method, I cannot get a reference to the EJB object? Why can't I just call getEJBObject() of session context?
Thanks.
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The container hasn't finished creating the ejb object yet. When you ask your context for the ejb object, you are expecting to get a reference to an object that is completely ready for use.... but setSessionContext is one of the very methods that the container is invoking in order to get the ejb object ready to be used. Its just too early in the lifecycle.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The sequence is
Constructor, setSessionContext and then ejbCreate. The ejbObject is created only at the point of ejbCreate call. So setSesionContext is little too early for the getEJBObject() call.
Dilli
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can call getEJBhome() because it is already there but not
getEJBobject() because it is not yet formed totally ...i mean a session bean (stateful) is linked with its sessioncontext & ejbObject only after setSessionContext() and ejbCreate() are called,so a Session bean knows its EJBObject after ejbCreate().
hope this helps.
 
Li Xin
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, got it! Thanks a lot!
 
Slime does not pay. Always keep your tiny ad dry.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic