• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HFE vs EJB Spec - session beans

 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
On p.228 of HFE, we can read that in ejbCreate and ejbRemove methods of stateless session beans, we are not allowed to get a transaction reference, and call methods on it (BMT only).
On, p.90 of EJB2.0 spec, it's clearly mentionned that we can call getUserTransaction on ejbCreate and ejbRemove methods of BMT stateless session beans (although it's not allowed to call setRollBackOnly and getRollbackOnly of CMT beans).
Which one to trust;-)?
Second question:
why is it allowed to access Ressource mananger and Enterprise Beans in ejbCreate, ejbRemove, ejbPassivate and ejbActivate methods of stateful session beans whereas it is not allowed for ejbCreate and ejbRemove methods of stateless session beans?
Thanks for your response,
Regards,
Cyril.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HF EJB says that its possible only for BMT .. And u can not call getUserTransaction on CMT stateless ....its the same thing that spec says ..

2. In stateless beans , ejbCreate() is not called when the client calls create() on home. But its called when the container thinks that its necessary to create the bean instances . So , the ejbcreate() doesnt have security context in case of SLSB.
but in SFSB(stateful session bveans) , jbCreate() is called when the client calles create() on home and hence ejbCreate() has security context available in it .
EJB spec says that access to resources and other beans is possible if the method has either transaction context or security context. Though both the SLSB and SFSB ejbCreate methods do not have transaction context , SFSB has security context . So , in SFSB , ejbCreate can access Res mgrs and other beans .
 
cyril vidal
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

HF EJB says that its possible only for BMT .. And u can not call getUserTransaction on CMT stateless ....its the same thing that spec says ..


Hmmm... I don't change my question: The spec says you may call getUserTransaction on BMT Beans (look at the right cell of the table p.90 for ejbCreate and ejbRemove methods) whereas HFE says it's not possible ( the box "get a transaction reference, and call methods on it BMT beans" is unchecked...p.228)
That's clearly different;-)
Regards,
Cyril.
 
Ramakrishna Allam
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah....U are right.
Infact ejbCreate() , ejbRemove() of both SFSB , SLSB are not in transaction context. So , setRollbackOnly and getRollbackOnly()(for CMT beans) methods cann not be accessed (in both SFSb and SLSB). this is true for ejbActivate() and ejbPassivate() methods of SFSB .
But in all the cases , if the bean is a BMT one , its possible to call the getUserTransaction() method in all the methods .(I do not undertsand why!!.When there is no transaction context running , (infact) when an unspecified tranction context is running , will it be possible to call getUserTransaction[ofcourse in BMT]). If that is the case , EJB spec should be right for the above Q'n . i.e getUserTransaction can be called from stateless ejbCreate and ejbRemove . Somebody please explain . this is really confusing .
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On page 90 of the spec. it says you can call getUserTransaction for BMT, but it does not say you can call methods on this UserTransaction.
Have a look at the business method row. There you can find the line "UserTransaction" methods.
 
Constantino Cronemberger
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another interesting thing to notice on page 80 of the spec. is that on ejbCreate you can access "enterprise beans" even though there is no meaningful transaction context. This goes against what is said on page 81:
"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."
 
Ramakrishna Allam
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Constantino,
I got this doubt earlier and got clarified in this forum only . SO , I will be enlightening u this time , thanks to my great helping nature :-)(just kidding) . EJB spec on page 81 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." . Observe the OR part as well , "client security context" . ejbCreate() , ejbRemove() , ejbActivate() and ejbPassivate() [4 methods] have client security conetxt though they do not have the transaction context.(that is the reason why we can call gerCallerPrincipa and isCallerInRole() in those methods) .So , we can access resource mgrs and other enterprise beans as well in those 4 methods. But only in case of SFSB . In case of SLSB , we have neither transaction context nor security context . So , we can not access resource mgrs and other beans .
If this is the case, i have got another doubt which hasnt been clarified . afterCompletion in CMT stateful method , though doesnt have transaction context , has a security conetext . But surprisingly, it doesnt have access to resource managers and other enterprise beans . If u understand why , please let me know.
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Constantino Cronemberger:
On page 90 of the spec. it says you can call getUserTransaction for BMT, but it does not say you can call methods on this UserTransaction.
Have a look at the business method row. There you can find the line "UserTransaction" methods.


Not sure if this is errata. I checked up EJB1.1 specs,
the same table, same row and column has "UserTransaction methods"
for ejbCreate()/ejbRemove() methods for SLSB. (p:74, 6.8.2, Table 3).
EJB1.1 has errata list on the website and this is not mentioned there.
But the same table mentioned in EJB2.0 and 2.1 specs, do not have this as
Constantino pointed out. So I am also confused , as nothing changed in Session beans from EJB1.1 to EJB2.1
Coming to Kathy's book, this is not mentioned in the Unconfirmed errata list at the OReilly site.
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ramakrishna Allam:
If this is the case, i have got another doubt which hasnt been clarified . afterCompletion in CMT stateful method , though doesnt have transaction context , has a security conetext . But surprisingly, it doesnt have access to resource managers and other enterprise beans.


- How can I forget this question ...I am trying to get the answer from other forums as well and will post the answer here, if I manage to get a convincing one. Hope Kathy/Bert would come around and post the correct explanation before that.
 
It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic