Forums Register Login

HFE vs EJB Spec - session beans

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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 .
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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 .
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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."
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
 

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.
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1264 times.
Similar Threads
getUserTransaction() in ejbCreate() for stateless session bean
Obtaining transction reference for stateless session beans
Unspecified Transaction Context
question about ejbCreate() and ejbRemove() in Stateless SB or MDB
Doubt in access of tx stuff in stateless and stateful bean
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:57:57.