This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes EJB Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "EJB Question" Watch "EJB Question" New topic

EJB Question

Prasad Kuppa
Ranch Hand

Joined: Apr 01, 2002
Posts: 151

Here is a question from one of the mock exams.

In CMP Entity Beans, which of the following statements is true?

a. The Entity Bean Class should not define any constructors
b. The Entity Bean class must define a no-argument constructor

The answer provided is (a). But is it correct? I don't see this in the EJB Spec. I think there is nothing wrong if the bean class provides empty constructor. Can anyone explain?


Goutam Bhattacharjee
Ranch Hand

Joined: Aug 05, 2003
Posts: 44
I think the catch lies in the sentence construction of the 2nd choice. Obvioulsy u can define a no-arg constructor, but is not mandatory. Thus ths 2nd choice which says: "must define a no-arg constructor" would not qualify

Stevica Vucicevic

Joined: Jan 07, 2005
Posts: 10

a) is write as you do not define a constructor in the implementation of an EJB, because there is the ejbCreate method, you use to create the bean. There is no impact if it is a BMP or CMP bean!

Look at the implementations in your guides, there is never any constructor, a class should normally have.

cheers stevica
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1168
Obviously the constructors don't play any role in CMP Entity Beans; all the creation is done via the ejbCreate method.

Prasad said:
I think there is nothing wrong if the bean class provides empty constructor.

There is nothing wrong with it, but providing this constructor doesn't serve any purpose.

BTW, I do see this constructor in a WebLogic 8.1 example.

I also didn't see any reference to this issue in the SUN FAQ EJB Restrictions page:


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Prasad Kuppa
Ranch Hand

Joined: Apr 01, 2002
Posts: 151
I am clear. Thank you all.

I agree. Here's the link:
subject: EJB Question
Similar Threads
Threads in EJB
Can I choose BMP along with CM transaction (EJB newbie) ?
Could I define CMR in different ejb-jar??
About the empty constructor
mock question : Please clarify