• 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Getting EJBObject from ejbCreate() on stateless bean

Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the spec (table on page 90), a stateless session bean can call getEJBObject from its ejbCreate() method. My understanding is that ejbCreate() is called when the bean is created, which does not necessarily relate to any client interaction, which means, presumably, that there will be no EJBObject. Is this right, and if so, what happens when getEJBObject is called in such a case. Does it return null (which can be checked for in code), or does it throw an exception?
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The stateless session bean case is quite simple. In fact, each stateless SB TYPE has ONE EJBObject. Which mean each client accessing the same type of stateless bean will access the SAME EJBObject.

Now on to the creation time. When client calls create(), what is actually created (if not already existing) is the EJBObject. Later, when the bean is needed for business method needs, then container calls its constructor, ties it to an EJBObject, sets its context, and then calls the ejbCreate() method. But at this time, the EJBObject for this type of stateless bean exists for a long time already, so its available in the ejbCreate() method.
    Bookmark Topic Watch Topic
  • New Topic