Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

HeadFirst EJB - AdviceBean - JNDI Question

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You are HERE! The other map is obviously wrong. Better confirm with this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic