Hi,
I am a newbie to
EJB and have just started reading the Headfirst EJB book. I've deployed the AdviceBean but can't access it from the client.
The client - AdviceClient - throws the following runtime error:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an
applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at AdviceClient.go(AdviceClient.java:19)
at AdviceClient.main(AdviceClient.java:11)
Here's the AdviceClient.java class source:
public class AdviceClient {
public static void main(
String[] args) {
new AdviceClient().go();
}
public void go() {
try {
Context ic = new InitialContext();
System.out.println("All's well so far");
Object o = ic.lookup("Advisor");
AdviceHome home = (AdviceHome)PortableRemoteObject.narrow(o, AdviceHome.class);
Advice advisor = home.create();
System.out.println(advisor.getAdvice());
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
My enviroment - Sun's Application Server 8.2, J2SE1.5, J2EE 1.4, and Windows XP.
What am I missing?
Thanks in advance,
Sarala