Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Default transaction context

 
Todor Mollov
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What if transaction descriptions are missed in DD. What kind of transactions will the container use ?
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't specify a transaction attribute in your DD where one is necessary, the application should blow up when you try to deploy it.
 
Todor Mollov
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't specify transaction attributes both for my entity and session beans and they deployed perfectly. Now I wonder what transaction mechanism will be used?
Any idea ?
 
Jack Zhou
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DD requires that transaction-type is required sub element of session and message-driven. Your container should detect this when it deployers your ejb-jar.jar file. May ask what container you are using?
 
Victor Lar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You did not specify what transaction attribute? What EJB container are you using?
 
Todor Mollov
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using JBoss 3.2.3.
Do you think that properly coded bean with the following DD will not deploy and run?

Pay attention that <aassembly-descriptor> part is misssing, the place where transaction attributes are specified(RequiresNew, Required, Never, etc...). If our uniquiely :-) named BeanStatefullBean has one method getSomething() for example, will the container start a transaction when this method is exected?
[ February 22, 2004: Message edited by: Todor Mollov ]
 
Victor Lar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic