Your problem here has nothing to do with EJB.  The code doesn't work because the first 
line of every constructor is a call to another constructor, either of the current 
class or the classes superclass.
If you omit a call to another constructor, then the line super() will be inserted 
automatically.  This is all clearly documented in the java language specs.

Since OrderTask's default constructor calls super() as the first line, and the 
superclass default constructor calls startup(), when OrderTask is constructed 
startup() will be called before the variable
someObject is initialized in the second line of OrderTask's default constructor.

"Rumble, Nick" wrote:

> But surely - someObject will be initialised because when the EJB container
> creates an instance of OrderTask, it's default constructor - OrderTask()
> will be called - and this will be done PRIOR to a call to ejbCreate().
>
> Is this true ?
>
> -----Original Message-----
> From: Hermann Schmitt [mailto:[EMAIL PROTECTED]]
> Sent: 19 October 1999 16:48
> To: [EMAIL PROTECTED]
> Subject: AW: Default class constructor verses ejbCreate() on SessionBean
>
> Hallo,
> I think, that makes no sense.
> ejbCreate is called by the home and according to your program calls startup
> which does something with someObject.
> But someobject is not yet created.
> Hermann Schmitt
> -----Urspr�ngliche Nachricht-----
> Von: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]Im Auftrag von Rumble, Nick
> Gesendet: Dienstag, 19. Oktober 1999 16:28
> An: [EMAIL PROTECTED]
> Betreff: Default class constructor verses ejbCreate() on SessionBean
> Wichtigkeit: Hoch
>
> Hi - I've a question about the legality of using a class's default
> constructor to perform some initialisation. This is best explained by
> example. I have an abstract Session Bean called "Adaptor" it's main task is
> to call the "startup" method within subclassed "real" Session Beans:
>
> public abstract class Adaptor implements SessionBean
> {
>
>         public void ejbCreate()
>                 throws RemoteException
>         {
>                 startup();
>         }
>
>         // Rest of SessionBean and Remote interfaces cut out for brevity
>
>         protected abstract void startup() ;
> }
>
> Example "real" session bean that can be instantiated by an EJB client:
>
> public class OrderTask extends Adaptor
> {
>         Object  someObject;
>
>         public OrderTask()
>         {
>                 someObject = new ..... ;
>         }
>
>         protected void startup()
>         {
>                 someObject.doSomething();
>         }
> }
>
> In this example, the default constructor for OrderTask() initialises/creates
> someObject and the startup() method - called indirectly by the default EJB
> constructor - "ejbCreate()" does something with it.
>
> Is this acceptable/legal ?
>
> Thanks in advance.
>
> Nick Rumble
>
> The statements and opinions expressed here are my own and may not represent
> those of the company.
>
> This e-mail is subject to copyright and the information in it is
> confidential. It is intended only for the named recipient. You are advised
> not to disclose the contents of this e-mail to another pers
> on or take copies of it.
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
> The statements and opinions expressed here are my own and may not represent those of 
>the company.
>
> This e-mail is subject to copyright and the information in it is confidential. It is 
>intended only for the named recipient. You are advised not to disclose the contents 
>of this e-mail to another pers
> on or take copies of it.
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
begin:vcard
n:Wilson;Chip
tel;fax:(214) 358-0353
tel;work:(214) 642-4559
x-mozilla-html:TRUE
url:http://www.axyssolutions.com/
org:Axys Solutions
adr:;;;Dallas;TX;;
version:2.1
email;internet:[EMAIL PROTECTED]
title:Application Architect
note:Sun Certified Java Architect
x-mozilla-cpt:;-25088
fn:Chip Wilson
end:vcard

Reply via email to