• 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
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Accessing another beans methods in setSessionContext()

Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The head first book says that you are not allowed to access another beans methods in setSessionContext (page 228 for stateless and 196 for stateful), however I managed to do so using the following code:

Is the book incorrect or have I mis-understood something?
Thanks for any help anyone can give.
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The EJB spec says that,

Accessing resource managers and enterprise beans is disallowed in the session bean methods
for which the Container does not have a meaningful transaction context or client security context.

It also says that

If a session bean instance attempts to access a resource manager or an enterprise bean, and that access is
not allowed (as state by the spec), the behavior is undefined by the EJB architecture.

So your code in theory could work it's just not gauranteed to work in all EJB containers. This hurts your EJB's potential for reusability.
HFEJB is saying what is mandated by the spec so you will need to know it for the exam.
Hope this helps,
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic