• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HeadFirst EJB - AdviceBean - JNDI Question

 
Sarala Rajagopalan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My enviroment - Sun's Application Server 8.2, J2SE1.5, J2EE 1.4, and Windows XP. What am I missing?

Just one advice. Head First EJB is aimed at SCBCD 1.3. You should be using J2EE1.3.1 RI and J2SE 1.3 instead.
 
Sarala Rajagopalan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! Couldn't locate the SDK for J2ee 1.3 on Sun and settled for 1.4. Went through the other postings on this board and finally found a link for 1.3 that worked. Shall try with the new setup.

Thanks again,

Sarala
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic