Hello Rahul ,
I second Luis on that. Forgetting to invoke setenv is the root of most
problems while beginning to write EJB programs.
Now there are two ways you could write your client program.
OPTION 1:
1. Construct a properties object
2. "Put" all the parameters like the InitialContextFactory and the provider
URL here.That is , hardcode it
3. Then pass this properties object to the constructor of InitialContext
object.
This is the way Luis has followed and suggested to you and probably is the
way it is followed in the Monson-Haefel book.
OPTION 2:
Do not hardcode the parameters as done in step 2 of OPTION 1. Club all
these steps by writing simply this line
Context ctx = new InitialContext(System.getProperties());
I am sure your code looks like this but to make your client more portable ,
you will have to specify all those parameters that you specified in OPTION 1
at the command line. Of course , this means more typing for you ( but i
think only once...which shouldnt be a problem). But if you understand the
objective behind Ed Roman preferring to write the client program the way he
does , you will realise why option 2 has its merits.Actually you can modify
this even more ....write a properties file for yourself and then make the
client program read from it. This can save you from typing the parameters at
command line and still avoid hardcoding.
Rgds,
(Another) Rahul
> -----Original Message-----
> From: Luis Canals [mailto:[EMAIL PROTECTED]]
> Sent: Monday, November 06, 2000 9:05 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Unable to start my first EJB sample.
>
>
> Hello Rahul,
>
> If you're using WebLogic Server 5.1.0 (not WebLogic
> Enterprise), your client
> must look like:
>
> java.util.Properties prop = new
> java.util.Properties();
> prop.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
> "weblogic.jndi.WLInitialContextFactory");
> prop.put(javax.naming.Context.PROVIDER_URL,
> "t3://myserver.mydomain:7001");
> ctx = new InitialContext(prop);
>
> I had a lot of problems when trying to execute examples of
> Roman Book; for
> example, the source 6.9. ;-)
> I would advise you to run firstly the weblogic\setEnv.cmd (or
> setEnv.sh if
> you have Unix), and then run the client without "-D"
> parameters: you don't
> need to define any environment variable.
> By the way, I think the best EJB book is Richard
> Monson-Haefel's (O'Reilly).
>
> Regards.
> Luis Canals.
>
> -----Original Message-----
> From: Rahul Naithani [mailto:[EMAIL PROTECTED]]
> Sent: lunes, 06 de noviembre de 2000 13:24
> To: [EMAIL PROTECTED]
> Subject: Unable to start my first EJB sample.
>
>
> Dear Ejb-Interest list,
> I made my first EJB application which constitutes of a
> stateless session
> bean at the server end and a simple java program at the client side.
> The server is deployed in Weblogic 5.1.0 and my jar file is in place.
> Just to avoid any problems, I copied the whole jar file in
> the directory
> which has my client and compiled the client successfully.
>
> But I am not able to find a way to execute this client. I
> went through Ed
> Roman's book and did exactly what's written there but still I
> get an error
> when I try to execute the client. This is the error:
> "Exception in thread "main"java.lang.NoClassDefFoundError:
> javax/naming/Context"
>
> On seeing this error I tried to look for a jar file in
> weblogic/lib which
> might be having a javax.naming.Context class. On finding such
> jar, which was
> weblogicaux.jar, and other naming stuff I tried to run the
> client like this
> at the command prompt:
> "java
> Djava..naming.factory.initial=weblogic.jndi.TengahInitialConte
> xtFactory -Dja
> va.naming.provider.url=t3://localhost:7001 -classpath
> e:\weblogic\lib\weblogicaux.jar HelloClient".
>
> But my bad luck still did not part company with me. Then I got an even
> longer error :) which is as follows:
> javax.naming.NoInitialContextException: cannot instantiate class:
> weblogic.jndi.TengahInitialContextFactory
>
> Can somebody be kind enough to tell me where can I find this
> TengahInitialContextFactory class so that I can add that too to my
> classpath. I have not been able to locate this class anywhere.
> Or is it not related to any classpath problem?
>
> Thank you in advance,
> Rahul Naithani.
>
> ==============================================================
> =============
> 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".
>
> This message and any files transmitted with it are
> confidential and intended
> solely for the use of the individual or entity to whom they
> are addressed.
> No confidentiality or privilege is waived or lost by any
> wrong transmission.
> If you have received this message in error, please
> immediately destroy it
> and kindly notify the sender by reply email.
> You must not, directly or indirectly, use, disclose,
> distribute, print, or
> copy any part of this message if you are not the intended recipient.
> Opinions, conclusions and other information in this message
> that do not
> relate to the official business of Newknow shall be
> understood as neither
> given nor endorsed by 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".