• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Common EJBObject and SessionBean interface

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wasn't getting any answers in the Bunkhouse Porch, so here's a link:
Bunkhouse Porch common interface question
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Interface can define to throw the RemoteException (in fact, any necessary exceptions), but the real class method does not necessary to throw such exception.

Nick
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My Question
Why the real class method does not necessary to throw such exception ?

My Answer
Because EJB Container is throws exception after have some error occur.

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


Why the real class method does not necessary to throw such exception ?



Because Java language specification allows method implementations to throw less checked exceptions than the inteface method has declared.

Eg,




[ July 21, 2004: Message edited by: Alex Sharkoff ]
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Why the real class method does not necessary to throw such exception


It is becos the real EJB class dont know what exceptions to be thrown, when there are some unexpected exception occurs.

For example, when there are not enough system resources, a system exception will be thrown. However, how come the EJB itself knows where is the client? Remote? (to throw RemoteException) or Local? (to throw EJBException).

Thus, the exception that really throw out is determined by the container, instead of the EJB object itself.

Nick
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for all comment.

It's clear....
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, since the bean class is same for both remote and local clients it does not make sense to throw RemoteException from the bean class.
 
Rick DeBay
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nicholas Cheung:
The Interface can define to throw the RemoteException (in fact, any necessary exceptions), but the real class method does not necessary to throw such exception.

Nick



Correct, although I hate declaring something like that if I'm not going to throw it. Code should be self documenting, and the throws signature implies that it does something it doesn't.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rick,
I posted this reply to your other post

You have to define 2 interfaces A and B, B extends A and have the same methods but without RemoteException. Parent interface A will declare RemoteException and your remote interface can extend it. Your bean will implement B which does not throw RemoteException. Child can specialize or not declare exceptions when overwriting operations from parent.
 
reply
    Bookmark Topic Watch Topic
  • New Topic