• 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

CreateException

 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 !!!
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Timothy Toe
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[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
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
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
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
 
Timothy Toe
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Crettaz, Thanks.

Will not let a possible grammar mistake screw me up.

 
Shiang Wang
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic