• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Client does not run

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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(NamingManager.java:6
40)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
a:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at AdviceClient.go(AdviceClient.java:21)
at AdviceClient.main(AdviceClient.java:12)

---------------------------CODE---------------------------------------------
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() {
try
{
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!!!");
System.out.println(advisor.getAdvice());
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}

----------------------------------------------------------------------------
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!
 
Tell me how it all turns out. Here is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic