aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Unspecified, but meaningful transaction? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Unspecified, but meaningful transaction?" Watch "Unspecified, but meaningful transaction?" New topic
Author

Unspecified, but meaningful transaction?

Mark Hoogenboom
Greenhorn

Joined: Jul 16, 2003
Posts: 4
LS,

The following confused me while reading the EJB 2.0 specs. In 7.5.7 it states that a session bean's ejbCreate and ejbRemove are called within an unspecificied transaction. In 7.6.1 I read that accessing resource managers and enterprise beans is dissallowed in the session bean's methods for which the Container does not have a meaningful transaction context. But the table on page 80 allows accessing resource managers and enterprise beans in the ejbCreate and ejbRemove methods. Does this mean that an unspecified transaction is a meaningful transaction?

thanks,
Mark
Christian D. Th. Sellberg
Greenhorn

Joined: Apr 02, 2004
Posts: 10
Hi Mark,

[I have edited my answer regarding stateful session beans]

The transaction context in ejbCreate and ejbRemove depends on the type of bean you are looking at. For entity beans, the containers call to the ejbCreate and ejbRemove methods is related to the client call and can therefore participate in the caller�s transaction and therefore access resource managers other enterprise beans etc. For stateless session beans and message driven beans the containers call to the ejbCreate and ejbRemove methods is not related to a client call and can therefore not participate in the caller�s transaction, in other words the transaction context is unspecified, i.e. you cannot write code that depends on a transaction being present.

For stateful session beans the transaction is also unspecified in ejbCreate and ejbRemove but the explanation given above does not apply here because the containers call to ejbCreate and ejbRemove is related to the client call. The spec gives the following reason (page 76)
-----
�. The ejbCreate and ejbRemove methods are not controlled by a transaction attribute because handling
rollbacks in these methods would greatly complicate the session instance�s state diagram. �.
-----
So for statefull session beans you can access resource managers and enterprise beans in ejbCreate and ejbRemove in a way that do not depend on a transaction being present.

Kind regards
Christian
[ July 09, 2004: Message edited by: Christian Sellberg ]
Mark Hoogenboom
Greenhorn

Joined: Jul 16, 2003
Posts: 4
Thanks Christian. Your explanation makes a lot more sense than the remarks in 7.5.7 and 17.6.5 about the transaction context of a session bean's ejbCreate en ejbRemove methods.

kind regards,
Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unspecified, but meaningful transaction?