aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes TransactionAttributeType.NEVER in Remote Interface 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 "TransactionAttributeType.NEVER in Remote Interface" Watch "TransactionAttributeType.NEVER in Remote Interface" New topic
Author

TransactionAttributeType.NEVER in Remote Interface

Mustafa Garhi
Ranch Hand

Joined: Nov 05, 2008
Posts: 111
Hi,

I read that NEVER can be useful when you do not want developers to write Database critical code in a method, so that if they do that an exception would result. So while trying to practice that at home, i tried to decorate my interface method declaration with attribute @TransactionAttribute(TransactionAttributeType.NEVER) but no exceptions were thrown when i call the Session Bean without already having a transaction. Surprisingly, when i decorated the Session Bean's method (as opposed to the method declaration in interface) itself with @TransactionAttribute(TransactionAttributeType.NEVER), the same call results in an Exception. I am using jboss 5. What went wrong here? Can i not use @TransactionAttribute(TransactionAttributeType.NEVER) in the Remote Interface itself?

Thanks
Asif
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10091
    
164

As per the EJB3.0 spec (section 13.3.7.1):

A transaction attribute may be specified on a method of the bean class to override the transaction attribute value explicitly or implicitly specified on the bean class.


So the transaction attribute is expected to be specified on the bean implementation class and not the interface(s).




[My Blog] [JavaRanch Journal]
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 449
    
    4
Hope this help:

http://download.oracle.com/javaee/5/tutorial/doc/bncij.html#bncirTable 33-1 Transaction Attributes and Scope


read this funny one Q/A http://stackoverflow.com/questions/1759554/examples-or-uses-cases-to-explain-ejb-transaction-attributes
Mustafa Garhi
Ranch Hand

Joined: Nov 05, 2008
Posts: 111
Thank you guys.

I don't know how easy it is to go through any specs but i definitely need to learn that.

Closing this issue.

Cheers
Mustafa
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TransactionAttributeType.NEVER in Remote Interface