Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Allowed operations for statefull session beans

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anybody know why ejbCreate/ejbRemove/ejbActivate/ejbPassivate -methods for SFSBs are allowed to do every possible bean things except call get/setRollbackOnly() (EJB 2.0 spec in page 80)? I assume there exists a meaningful tx context in those methods since it's allowed to call other beans and access resource manager from them.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
"All possible bean things" are allowed in BMT stateful session beans only. But when you use BMT, you are not allowed to use get/setRollbackOnly(). Instead you can call commit() or rollback()
Regards,Viktor
 
Janne Karhu
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm aware that BMTs can never call get/setRollbackOnly() (at least not without getting IllegalStateException), but the page I mentioned in the spec claims that even CMT beans cannot call those methods in ejbCreate/Remove/Activate/Passivate.

Originally posted by Viktor Sadovnikov:
Hi,
"All possible bean things" are allowed in BMT stateful session beans only. But when you use BMT, you are not allowed to use get/setRollbackOnly(). Instead you can call commit() or rollback()
Regards,Viktor

 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Does anybody know why ejbCreate/ejbRemove/ejbActivate/ejbPassivate -methods for SFSBs are allowed to do every possible bean things except call get/setRollbackOnly() (EJB 2.0 spec in page 80)? I assume there exists a meaningful tx context in those methods since it's allowed to call other beans and access resource manager from them.


I think the assumption is leading you off track. All 4 of those methods execute with an unspecified transaction context [spec section 7.5.7, page 76]. I've yet to see anything in the spec that guarantees that there will actually be a transaction context. It makes sense when you think about it... the whole point of CMT rollbacks is to cause a bunch of related method invocations and the resources they used to participate in the same transaction, but SFSB container callbacks don't participate in those transactions, so rollback isn't relevant.
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the next page (page 81), it is stated that


The ejbCreate<METHOD>, ejbRemove, ejbPassivate, and ejbActivate methods
of a session bean with container-managed transaction demarcation execute with an unspecified transaction context. Refer to Subsection 17.6.5 for how the Container executes methods with an unspecified transaction context.


I assume there exists a meaningful tx context in those methods since it's allowed to call other beans and access resource manager from them.
Being allowed to call other beans' methods does not necessarly mean that a meaningful transaction context exists...
 
Janne Karhu
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replies. I understand your point - the 4 methods of SFSBs are in the unspecified tx context and thus no set/getRollbackOnly() can be called. Anyways, in page 81 of the spec it is also said:


The reasons for disallowing the operations in Table 2 follow:
...
� Invoking the getRollbackOnly and setRollbackOnly methods is disallowed in the
session bean methods for which the Container does not have a meaningful transaction context,
and to all session beans with bean-managed transaction demarcation.
...
� 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.


This quote is very annoying from the logical perspective; how come the 4 methods can access resource managers and ejbs (and thus they seem to have meaningful tx context), but they cannot access the aforementioned get/setRollbackOnly() methods (and thus they do not have a meaningful tx context ?
 
Forget Steve. Look at this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic