Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

EJB compiled but not

Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello and Thanks everyone for help regarding compilation:

I wrote an application client to execute function on EJB, Client Code is this:
"try {
Context ic = new InitialContext(); // entry point in JNDI service
System.out.println("first line executed");
Object o = ic.lookup("AdviceHome"); // lookup for Advice Bean
System.out.println("second line executed");
AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o, AdviceHome.class);
System.out.println("third line executed");
Advice advisor = home.create();
System.out.println("fourth line executed");
System.out.println( advisor.getAdvice() );


It compiles well but when I tried to execute, it issues following error on 3rd line :

"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(
at javax.naming.InitialContext.getDefaultInitCtx(
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
at javax.naming.InitialContext.lookup(
at AdviceClient.go(
at AdviceClient.main(
Posts: 531
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should provide some information about your InitialContext
Create a hashtable and put some variable which is reauired for initializing the Context
you should provide:
1- a javax.naming.Context.PROVIDER_URL
2- javax.naming.Context.INITIAL_CONTEXT_FACTORY

first one is a url like : iiop://....

second one is a class qualified name like

so add this two to a hashtable and pass the hashtable to initialContext Constructor.

hope it helps
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic