aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Errata in Valentin Crettaz's cheat sheets 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 "Errata in Valentin Crettaz Watch "Errata in Valentin Crettaz New topic
Author

Errata in Valentin Crettaz's cheat sheets

Jose Esteban
Ranch Hand

Joined: Nov 28, 2004
Posts: 102
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 ]
Andree Charfen
Ranch Hand

Joined: Mar 24, 2004
Posts: 32
I am interested in getting those sheets! Do you know where I can get them?

Thank you!


yeeeehhhhaaaaaa<br />(riding the JVM)
Andree Charfen
Ranch Hand

Joined: Mar 24, 2004
Posts: 32
Never mind I found them. Thanks anyways!
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Jose Esteban
Ranch Hand

Joined: Nov 28, 2004
Posts: 102
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
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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

Joined: Nov 28, 2004
Posts: 102
Thank you for sharing your cheat sheets.

Jose
Jose Esteban
Ranch Hand

Joined: Nov 28, 2004
Posts: 102
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
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Errata in Valentin Crettaz's cheat sheets
 
Similar Threads
Exception Handling in MDB
RemoteException in EJB 3
Deprecated Methods and Exception
Veletin's Cheet Sheets
Question on cheat sheets and Zaikin material