File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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: 10441

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: 471
Hope this help: 33-1 Transaction Attributes and Scope

read this funny one Q/A
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.

I agree. Here's the link:
subject: TransactionAttributeType.NEVER in Remote Interface
It's not a secret anymore!