• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Can a stateless bean throw a remote exception (Enthuware)?

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is from Enthuware Test 1 Q1:

The important thing to remember is that FinderExceptions, CreateException, and RemoveException are checked application exceptions and must be declared in the throws clause of the method.

Also, beans are not allowed to throw RemoteException. It is the container's responsibility to throw it to the client if the client is a remote client.

Therefore, this code can only throw an EJBException, which is a RuntimeException.



However I wrote a quick test and the container (JBoss) did not have an issue with it:



Am I missing something here or is this merely a recommendation of the EJB3 specification?
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In EJB 3.0 with @Remote annotation business methods need not to to throw
java.rim.RemoteException.

If you throw, its no harm but in fact it is no required.
[ November 30, 2008: Message edited by: Chandra Bhatt ]
 
Enthuware Software Support
Posts: 4584
45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no Java langauge requirement that beans cannot throw RemoteException. So when you say that Beans are not allowed to throw RemoteException, it is not the compiler but the EJB specification that you are talking about. For example, if you say that a bean method is not allowed to call System.exit(0);, it means that the EJB specification forbids it, not Java language/compiler. So you can call System.exit(0) but, obviously, it would be a wrong thing to do.

Having said that, your confusion is valid and further clarification has been added to the explanation.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic