• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Allowed operations for statefull session beans

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Create symphonies in seed and soil. For this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic