File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Client does not run - NoInitialContextException ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Client does not run - NoInitialContextException !" Watch "Client does not run - NoInitialContextException !" New topic

Client does not run - NoInitialContextException !

Loukas G

Joined: Mar 04, 2004
Posts: 7
Hi, I am new at EJB and i read Head First EJB.I use Windows XP,J2EE Reference Implementation and J2SDK 1.4.2.When i tried to run the first example and specifically the client (AdviceClient) the following message was displayed:
E:\source\projects\advice>java AdviceClient
Context Created!!!
javax.naming.NoInitialContextException: Need to specify class name in environmen
t or system property, or as an applet parameter, or in an application resource f
ile: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(
at javax.naming.InitialContext.getDefaultInitCtx(
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
at javax.naming.InitialContext.lookup(
at AdviceClient.go(
at AdviceClient.main(

import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;

public class AdviceClient
public static void main(String[] args)
new AdviceClient().go();
public void go() {
Context ic = new InitialContext();
System.out.println("Context Created!!!");
Object o = ic.lookup("Advisor");
System.out.println("Lookup DONE!!!");
AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o, AdviceHome.class);
System.out.println("Narrowing DONE!!!");
Advice advisor = home.create();
System.out.println("Remote Object Created!!!");
catch (Exception ex)

Now from the message i think that somewhere i must specify the properties of InitialContext.Am i right and if i am where and how can i do this? Kathy,Bert HELP please!
Lahiru Abeydeera
Ranch Hand

Joined: Nov 05, 2004
Posts: 44
I'm also having the same problem. Do we have to give any JNDI parameters? . Anyway I know it's something wrong with the client not EJB. Because it worked when i used a servlet
Can anyone help me?

Thanx in advance!
I agree. Here's the link:
subject: Client does not run - NoInitialContextException !
It's not a secret anymore!