• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Accessing another beans methods in setSessionContext()

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
What is that? Is that a mongol hoarde? Can we fend them off with this tiny ad?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic