This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

HFEJB - pag 564 - exception question

 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks!!!

As far the question number 5, why isn't the option A correct as well since it also guarantees that there will be a TX actives?

On the page 552, i can see these:

"The container throws this to the caller when the container can't commit the transaction and the caller invoked the method within an existing transaction context. But the container will not throws this exception if the failure to commit is because the bean explicitly called setRollBackOnly() method!".

So i cannot see here it means that we really need to have that by using the "mandatory" attribute.

Tks guys!!!
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question clearly asks"In which case will the container always throws a TransactionRolledBackException"

"The container throws this to the caller when the container can't commit the transaction and the caller invoked the method within an existing transaction context"

"Requires new" attribute does not signifies an already existing transaction context as in this case, the method will always run with a new transaction not with an existing transaction , which is required condition for this exception.

In case of "RequiresNew" attribute, if the method is called with an existing transaction context, the caller's transaction is suspended until the method completes(refer pageno: 494).

Mandatory means "Requires Existing".
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If use "RequireNew", then the method always on the new transaction, it cannot prove the method's caller is in an existing transaction. So container will not already throw TransactionRolledbackException. When caller is in the transaction, the method with "RequireNew" will throw TransactionRolledbackException. But when caller is not in the transaction, container will not throw.

Here, I got a question:
when caller is not in the transaction, then the method with "RequireNew" throws a system exception, what exception the container will finally throw?
I think container will throw RemoteException for remote client, EJBException for local client.
 
neetika sharma
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah you are correct,

when Bean method runs in the context of a transaction that the Container started immediately, i.e marked with attribute "RequireNew" and throws a system exception then the container will throw RemoteException to REMOTE client/ EJBException to LOCAL client.
 
Napu Sun
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Neetika
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic