aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes CreateException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "CreateException" Watch "CreateException" New topic
Author

CreateException

Timothy Toe
Ranch Hand

Joined: Oct 19, 2002
Posts: 156
Referring to the EJB 2.0 Spec on Session Beans...

--------------------------
7.10.3 ejbCreate<METHOD> methods

The throws clause may define arbitrary application exceptions, possibly including the javax.ejb.CreateException.


7.10.6 Session bean's remote home interface

The throws clause must include javax.ejb.CreateException.
------------------------------


Referring to the EJB 2.0 Spec on Entity Beans...

-------------------------------
10.6.4 ejbCreate<METHOD> methods

The throws clause must define the javax.ejb.CreateException.


10.6.10 Entity bean's remote home interface

The throws clause of a create<METHOD> method must include the javax.ejb.CreateException.
----------------------------------------


It is a MUST for create() in home interface but NOT A MUST for ejbCreate() in the Bean. Why ?
Isn't that all application exceptions must match between
create and ejbCreate,
remove and ejbRemove and
find and ejbFind ?


This issue struck me when I saw that on page 268 of HF-EJB does not have a CreateException for its ejbCreate in the CustomerBean EB.


To add to my confusion, in the Spec :
------------------------------
10.7.3 ejbFind<METHOD> methods

The throws clause must define the javax.ejb.FinderException.
------------------------------
but on the same page of HF-EJB, those ejbFind<methods> do not throw !


Please clarify. Thanks !!!
Shiang Wang
Ranch Hand

Joined: Jun 20, 2003
Posts: 96
CreateException and FinderException are application exception, unless you throw them in the method, you can't declare them. Compiler will not pass.

Entity bean is the only bean that requires ZERO or more create method. You have to have create method in the home, hence no need in entity bean class. Plus create in entity bean works like insert. If you don't want users to be able to insert records to the database, it makes sense without create method. Does that answer your question ?

Shiang


SCBCD, SCWCD, SCJP
Timothy Toe
Ranch Hand

Joined: Oct 19, 2002
Posts: 156
[CreateException and FinderException are application exception, unless you throw them in the method, you can't declare them. Compiler will not pass.]

I think this statement of yours is incorrect. I have written a small program to prove it.




NoSuchFieldException is a Checked Exception/App Exception. It extends java.lang.Exception.

Although my method go() declares NoSuchFieldException but does not throw it, it compiles (and runs) fine.

[ December 22, 2004: Message edited by: Timothy Toh ]

[ December 22, 2004: Message edited by: Timothy Toh ]
[ December 22, 2004: Message edited by: Timothy Toh ]
Timothy Toe
Ranch Hand

Joined: Oct 19, 2002
Posts: 156
Still don't understand why

SB:
ejbCreate in bean - POSSIBLY INCLUDING the javax.ejb.CreateException.
create in home - MUST include javax.ejb.CreateException.

Thanks.
Timothy Toe
Ranch Hand

Joined: Oct 19, 2002
Posts: 156
Can anybody give me a clue ?

I don't have problem with EB... since create methods in both home and bean are mandatory.

My problem is with SB.

Thanks.
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
I think this is just a grammatical problem. You have to know that the EJB spec has undergone three different releases (1.0, 1.1, 2.0 and now 2.1) and updates might not always be 100% accurate and correct. I would not focus on that too much, just declare CreateException in the ejbCreate() signature and you'll be well off

Your next question might be "what if the exam asks whether it is mandatory to declare CreateException in the throws clause of the ejbCreate() method of session bean?" and I would answer that the options will be formulated in a way that makes it clear what the correct answer is


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

Joined: Oct 19, 2002
Posts: 156
Crettaz, Thanks.

Will not let a possible grammar mistake screw me up.

Shiang Wang
Ranch Hand

Joined: Jun 20, 2003
Posts: 96
Timothy:

I agree with Valentin, just move on with other subjects. I myself experienced subtle differences in the spec and Weblogic, JBoss.
One thing you can relex is there are no ambiguious questions in the real exam. Almost every question, you know what its intention is for.

Shiang
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CreateException