• 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 ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Accessing another beans methods in setSessionContext()

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
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.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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,
Mike
 
Yes, my master! Here is the tiny ad you asked for:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic