aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Which the default trans-attribute for all Stateless SB methods ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Which the default trans-attribute for all Stateless SB methods ?" Watch "Which the default trans-attribute for all Stateless SB methods ?" New topic
Author

Which the default trans-attribute for all Stateless SB methods ?

Adilson Jardim
Greenhorn

Joined: Feb 27, 2004
Posts: 10
Hi,

I have this Stateless Session Bean CMT class



and this ejb DD:


Question:
Which the <trans-attribute> is assumed by container for all methods of MyBean ?

Thanks for all!
Alex Sharkoff
Ranch Hand

Joined: Apr 11, 2004
Posts: 209
Hi Adilson,

EJB 2.0 spec explicitly indicates that the transaction attributes must be defined for certain methods of ejbs (spec's section 17.4.1):

The transaction attribute must be specified for the following methods:
  • For a session bean, the transaction attributes must be specified for the methods defined in the bean�s component interface and all the direct and indirect superinterfaces of the component interface, excluding the methods of the javax.ejb.EJBObject or javax.ejb.EJBLocalObject interface. Transaction attributes must not be specified for the methods of a session bean�s home interface.
  • For an entity bean, the transaction attributes must be specified for the methods defined in the bean�s component interface and all the direct and indirect superinterfaces of the component interface, excluding the getEJBHome, getEJBLocalHome, getHandle, getPrimaryKey, and isIdentical methods; and for the methods defined in the bean�s home interface and all the direct and indirect superinterfaces of the home interface, excluding the

  • getEJBMetaData and getHomeHandle methods specific to the remote home interface.
  • For a message-driven bean, the transaction attribute must be specified for the bean�s onMessage method.



  • In theory I'd expect Container to complain when it finds that one (or more) ejb has no transaction attributes defined on its methods. However, in practice it looks different. Eg, JBoss assumes Required trans attribute on the methods that have no transaction attributes defined in ejb-jar.xml. I am not sure about other app servers

    I guess the bottom line is this - Application Assembler (or Deployer) has to always define transaction attributes for all methods that must have these attributes defined.

    Hope it helps
    [ July 15, 2004: Message edited by: Alex Sharkoff ]

    Alex (SCJP 1.4, SCBCD 1.3, SCWCD 1.4, SCJD 1.4)
    Adilson Jardim
    Greenhorn

    Joined: Feb 27, 2004
    Posts: 10
    Thanks Alex !

    This is the exactly that I needed!
    I am using the JBoss!

    I think that if no default attribute was assumed by the container would be more easy to discover given that one exception would be launched in start of the server.

     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Which the default trans-attribute for all Stateless SB methods ?