wood burning stoves 2.0*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Create methods throwing the unchecked exceptions... 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 "Create methods throwing the unchecked exceptions..." Watch "Create methods throwing the unchecked exceptions..." New topic
Author

Create methods throwing the unchecked exceptions...

Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205
Hi,

I am having some basic doubt, please clarify.

Why create methods of home interface and business methods of component interface can not throw the unchecked execptions?

If create methods of home interface or business methods of component interface are throwing the unchecked exceptions, Will it give compile time error. Or Is it part of J2EE specifications??

Please clarify.....


Narasimha
Jef Cumps
cowbird
Ranch Hand

Joined: Nov 14, 2001
Posts: 53
Hi,

As a bean provider, you can and should always wrap checked exceptions that the client is not expecting (not declared in your interface) in an EJBException, and throw that EJBException. You don't have to declare the EJBException in your home or component interface. The compiler won't complain...

If your business logic encounters runtime exceptions, just let them propagate to the container.

I'm not really sure the specs allow you to declare runtime exceptions... anyone else ?

If you create your own application exceptions, they should not extend RuntimeException or RemoteException. You need to declare those application exceptions in your bean class and your home or component interface if you throw them.

Hope this helps.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
These posts may be useful.

http://www.coderanch.com/t/159301/java-EJB-SCBCD/certification/CreateException-FinderException

http://www.coderanch.com/t/314042/EJB-JEE/java/Should-Bean-developer-throw-RemoteException

http://www.coderanch.com/t/314032/EJB-JEE/java/Exception


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Create methods throwing the unchecked exceptions...