• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Please help me on Exceptions and EJB-QL.

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Can U give me some help on these Questions and also tell me where to read to get a good level of confidence in EJB-QL.I read HFEJB.But I want to know more in that bcos many people in java ranch told to be more confident in that.
1.What happens when MDB onMessage method catches an Application Exception?
2.Bean realizes that it cant commit transaction,but it doesn't want the client to get an exception,what can the bean do.
3.Bean wants a client to get an application exception,but the bean still wants the transaction to commit.What should the beand do.

I think 1A..Will the bean through EJBException.
2A..can it say setRollBackOnly()
3A..
Please verify me the answers.

Thanx a lot in advance.
Vijaya
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.What happens when MDB onMessage method catches an Application Exception?

Well, tricky one. Actually, since an MDB has no client view, it must not throw application exceptions. It doesn't make big sense for an MDB to throw and application exception and catch it in the same method. The only thing it could do then, would be to wrap it in an EJBException which would be caught by the container. The container would then log the exception, rollback the transaction and discard the MDB anyway. The bottom line is that it is not worth throwing and catching an application exception in the same method and wrap it in a system exception. Why not throw the system exception right away?

2.Bean realizes that it cant commit transaction,but it doesn't want the client to get an exception,what can the bean do.

Nothing, an exception is thrown in all cases according to the spec. Check out cheat sheet on exception handling for more details.

3.Bean wants a client to get an application exception,but the bean still wants the transaction to commit.What should the beand do.

The bean itsefl cannot do much when application exception occur as they are thrown unchanged to the client. In case, the bean uses CMT, the container will try to commit/rollback the transaction depending on what getRollbackOnly() returns. Otherwise, the burden of committing/rolling back the transaction lies on the client as depicted on my above-mentioned cheat sheet.

Hope this helps
 
reply
    Bookmark Topic Watch Topic
  • New Topic