• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Getting EJBObject from ejbCreate() on stateless bean

Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic