• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Errata in Valentin Crettaz's cheat sheets

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm preparing the SCBCD exam and I have detected an errata in Valentin Crettaz's cheat sheets.

In every bean class the sheet says:
public void ejbPassivate()throws RemoteException, EJBException {...}
(and it is similar for the other methods from the implemented interface)

Well, the RemoteException should be deleted, because according to EJB 2.0 API:

"java.rmi.RemoteException - This exception is defined in the method signature to provide backward compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the EJB 1.1 specification should throw the javax.ejb.EJBException instead of this exception. Enterprise beans written for the EJB2.0 and higher specifications must throw the javax.ejb.EJBException instead of this exception."

It would be great if Valentin corrects the errata in his wonderful cheet sheets.

Thanks.
[ October 11, 2005: Message edited by: Jose Esteban ]
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am interested in getting those sheets! Do you know where I can get them?

Thank you!
 
Andree Charfen
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never mind I found them. Thanks anyways!
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jose,
You're absolutely right... BUT the cheat sheet is still correct as it is.

Here is why:

In the cheat sheet, you can see how your bean class should look like, i.e. which method declarations it should comprise and how those method declarations should be declared. What you mention from the spec is correct. EJB 2.0 compliant beans should not THROW java.rmi.RemoteException... but they still have to declare the exception in the throws clause of their methods since your bean classes must implement the javax.ejb.EntityBean interface and/or the javax.ejb.SessionBean interface and RemoteException is a checked exception.

I know this is as unintuitive as it gets but you'll have to deal with it... at least until EJB 3.0
 
Jose Esteban
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Valentin,
I understand what you mean but I don't agree with you in a thing:

Originally posted by Valentin Crettaz:
...but they still have to declare the exception in the throws clause of their methods since your bean classes must implement the javax.ejb.EntityBean interface and/or the javax.ejb.SessionBean interface and RemoteException is a checked exception.


The fact that a method in an interface declares an exception doesn't mean that the implementing method has to declare this exception (this is SCJP ). What is true is that you must not declare any new checked exceptions for an implementation method.

I agree that according to the "Java law" it should work (for the moment, because it is DEPRECATED) declaring the RemoteException , but what I can say for sure is that it is not mandatory. If you declare it (what I don't recommend since it is deprecated), it should be between square brackets. You can find lots of code to check what I say.

Besides, according to EJB 2.0 spec, section 18.3.8 (Support for deprecated use of java.rmi.RemoteException) the use of RemoteException in "business methods, ejbCreate, ejbPostCreate, ejbFind<METHOD>, ejbRemove, and the container-invoked callbacks (i.e., the methods defined in the EntityBean, SessionBean, and SessionSynchronization interfaces)" is deprecated.

So if you declare RemoteException in ejbActivate, to be consistent, you should do the same in every method mentioned in the last paragraph. But I really don't think that using deprecated expressions is correct (at least, without warning about it).

CONCLUSION:
1) I propose you not to use any deprecated expressions, although they work for the moment, and DELETE any reference to RemoteException in the bean classes. HFEJB also says this in pages 233 and 235: "You MUST not declare RemoteException in your bean class, EVER."

2) ANY OTHER exceptions in the bean classes should be optional. This includes CreateException in the ejbCreateMethods and EJBException in all of the bean classes.

I hope that these suggestions will allow your cheat sheets, which are close to perfection, to get it.
[ April 27, 2005: Message edited by: Jose Esteban ]
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, I think I have misunderstood you. It is indeed correct that RemoteException does not need to be declared in the throws clause of the callback methods. If the body does not throw RemoteException as mandated by the spec, it is possible not to declare it in the throws clause...

I will correct the cheat sheet by tomorrow. Thanks for spotting the mistake, Jose
 
Jose Esteban
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for sharing your cheat sheets.

Jose
 
Jose Esteban
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Valentin Crettaz:
I will correct the cheat sheet by tomorrow.


Hi Valentin, it seems that you have forgotten to correct the sheets. Please, don't forget to do it when you have a minute.

To facilitate your job, remember that the corrections that I propose are:
1) I propose you not to use any deprecated expressions, although they work for the moment, and DELETE any reference to RemoteException in the bean classes. HFEJB also says this in pages 233 and 235: "You MUST not declare RemoteException in your bean class, EVER."

2) ANY OTHER exceptions in the bean classes should be optional. This includes CreateException in the ejbCreateMethods and EJBException in all of the bean classes.

Regards,
Jose
[ May 05, 2005: Message edited by: Jose Esteban ]
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Jose, I have not forgotten to do the update, I just have a hard time finding a slot in my schedule... It's still very high in my priority list I'll post a message when I'm done. Thank you for your comprehension.
reply
    Bookmark Topic Watch Topic
  • New Topic