• Post Reply Bookmark Topic Watch Topic
  • New Topic

Another Tricky Mock Exam Question  RSS feed

 
Gareth Llewellyn
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, this time I have a mock exam question concerned with Exceptions.
The debate I have is with the interface hierarchy quoted in the question:

If a remote client in a transaction context invokes a business method on a bean with container-managed transaction (the business method has transaction attribute as either Required, Mandatory, and Supports) and the bean throws a non-application exception, the transaction is marked for rollback. The client then receives javax.transaction.TransactionRolledbackException (subclass of java.rmi.RemoteException) which indicates that the transaction has definitely been marked for rollback.

Whats the problem? Well HFEJB quotes TransactionRolledbackException as deriving from javax.ejb NOT javax.transaction. Which is correct?
 
B.Sathish
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can assure you that the HFEJB is wrong w.r.t this. It's javax.transaction.TrasnsactionRequiredException and javax.transaction.TransactionRolledbackException. Only the local counterparts are in the javax.ejb package. The spec is clear on this. This is mentioned in the "Unconfirmed errata" of the book. Recommend you to have a look at both the confirmed and unconfirmed errata
 
Gareth Llewellyn
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So its...

Remote checked Exceptions:
(subclasses of java.rmi.RemoteException)
javax.transaction.TransactionRolledbackException
javax.transaction.TransactionRequiredException

Local unchecked Exceptions:
(subclasses of javax.ejb.EJBException)
javax.ejb.TransactionRolledbackLocalException
javax.ejb.TransactionRequiredLocalException
[ November 17, 2005: Message edited by: Gareth Llewellyn ]
 
B.Sathish
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope, as I already said, the local exceptions are all from the javax.ejb package.

java.rmi.RemoteException
java.rmi.NoSuchObjectException
javax.transaction.TransactionRequiredException
javax.transaction.TransactionRolledbackException

javax.ejb.EJBException
javax.ejb.NoSuchObjectLocalException
javax.ejb.NoSuchEntityException
javax.ejb.TransactionRequiredLocalException
javax.ejb.TransactionRolledbackLocalException

The only mistakes in HFEJB are the package for TransactionRequiredException and TransactionRolledbackException
 
Ramakrishnan Viswanathan
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is mentioned in the
unconfirmed errata.

Please also take a look at the confirmed errata and make necessary updates to your copy of the book.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!