aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Can a stateless bean throw a remote exception (Enthuware)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Can a stateless bean throw a remote exception (Enthuware)?" Watch "Can a stateless bean throw a remote exception (Enthuware)?" New topic
Author

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

Jarrod Felino
Greenhorn

Joined: Nov 15, 2008
Posts: 26
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?
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
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 ]

cmbhatt
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3204
    
    2
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.


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can a stateless bean throw a remote exception (Enthuware)?
 
Similar Threads
Mikalai Zaikin SCBCD5.0 example problem
ejb create() Error java.lang. IllegalStateEx: Failed to find method for hash
RMI server startup exception
Stub cannot be cast to Interface
Calling EJB from servlet