This week's giveaway is in the Java in General forum.
We're giving away four copies of Java Challengers and have Rafael del Nero on-line!
See this thread for details.
Win a copy of Java Challengers this week in the Java in General forum!

Victor Lar

Greenhorn
+ Follow
since Feb 20, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Victor Lar

That was an interesting question. It might depend on the container implementation. EJB spec said that if transaction attributes are not specified for the methods of an enterprise bean, the Deployer will have to specify them. Also providing an assembly-descriptor in the deployment descriptor is optional for the ejb-jar file producer. I guess when bean is deployed methods are assigned some default transaction attribute value. I tested it on WebSphere 5.1. It also allows to omit assembly-descriptor. I created 3 beans: bean1.method() which calls bean2.method() which calls bean3.method(). bean1.method() has transactional attribute Never, I did not specify anything for bean2.method(), bean3.method() has Mandatory. When I call bean1.method() from a client it did not throw any exceptions. So I assume for WebSphere 5.1 when transactional attribute is not specified for
the method of CMT bean it will use Required or RequiresNew( you would have to refine this test more to find out if it is Required or RequiresNew)
I changed this test. I set bean1.method() to RequiresNew and before returning from bean2.method() I called setRollbackOnly() in bean2.method(). Then I printed getRollbackOnly() in bean1.method() and it was set to true. It means they were using the same transaction. So if you don't specify transactional attribute for WebSphere 5.1 it will be set to Required.
[ February 22, 2004: Message edited by: Victor Lar ]
I tried to do it in WebSphere 5.1 and it did not allow me to call begin(): it throws NullPointerException in com.ibm.ejs.container.UserTransactionWrapper.begin(UserTransactionWrapper.java:185)
But it works fine when I called getUserTransaction().getStatus(): it returned STATUS_NO_TRANSACTION.
You did not specify what transaction attribute? What EJB container are you using?
I think they meant using <unchecked/> tag and it is defined for classes not for instances.
You should be able to update the database in afterCompletion(). You don't need transactions to write to the database.
It is probably a misprint on page 228 in "head first ejb" book. Stateless BMT bean should be able to begin a new transaction in ejbCreate().
It is not only grayed out but also checkboxes are not checked. It means that CMT beans are not allowed to force a transaction to rollback or find out if the transaction has already been set to rollback inside ejbActivate() and ejbPassivate() methods