File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create methods throwing the unchecked exceptions...

 
Narasimha Rao B.
Ranch Hand
Posts: 205
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.....
 
Jef Cumps
cowbird
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic