Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Handle exception in Facade

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

My client is a SWT client and the server expose stateless session beans as facade.

i want to consult with you about handling excpetions:

1.Commit is called after the facade method was ended, so in case that the commit was failed due to database integrity the facade will not catch this excpetion and this excepytion will be thrown to the client without the ability to handle this exception? how do you solve this issue in your facades?

2.do you think that in the facade i should catch all exception and call to roleback in case of exception. a good reason for this is that the client can get a ClassNotFoundException in case that the Exception class in not in is classpath
 
author & internet detective
Posts: 41085
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Avihai,
I think the code that handles the commit should handle the rollback. Does the transaction cross multiple session bean calls? If not, the database has some tables/data locked for longer than necessary.

You can define your own checked exception and put it in your method signature. That would guarantee the client has it in the classpath.
 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont have a code to handle the commit.
The facade is stateless session bean (CMT = Container managed transaction), so the transaction commited in the end of the method.
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Avihai,

You stateless session bean should throw a RemoteException which you could catch on the SWT side just to display a user friendly exception.

If you want to handle the error on the server side just create a new method that actually has all the business logic and encapsulate it with your current business method. You should be able to catch Exceptions on your EJB later and send some user-friendly message to the client.
 
You can thank my dental hygienist for my untimely aliveness. So tiny:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic