Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Create methods throwing the unchecked exceptions...

 
Ranch Hand
Posts: 205
  • 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.....
 
cowbird
Posts: 53
  • 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.
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic