wood burning stoves 2.0*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "TransactionAttributeType.NEVER in Remote Interface" Watch "TransactionAttributeType.NEVER in Remote Interface" New topic

TransactionAttributeType.NEVER in Remote Interface

Mustafa Garhi
Ranch Hand

Joined: Nov 05, 2008
Posts: 111

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?

Jaikiran Pai

Joined: Jul 20, 2005
Posts: 9956

As per the EJB3.0 spec (section

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: 395
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.

wood burning stoves
subject: TransactionAttributeType.NEVER in Remote Interface
Similar Threads
Session EJB 3.1 inheritance
an exception question.
RollbackException and PersistentContext
Default transaction Attribute value
doubt at respect TransactionRequiredException