This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

NoInitialContextException :- running AdviceClient

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everybody,
I have started to read HF EJB, i am new to this EJB. this is my first example in EJB. I hereby complied the program of AdviceBean from the HF book. I am also using J2EE RI server. I have succesfully deployed & created AdviceAppClient.jar file & complied the AdviceClient.

when i wanted to run this it is throwing an error. i have tried in two ways as follows:-

1)
D:\projects\advice>java -cp "j2ee.jar;AdviceAppClient.jar" AdviceClient
Exception in thread "main" java.lang.NoClassDefFoundError: AdviceClient



2) D:\projects\advice>java AdviceClient
avax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.nami
g.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at AdviceClient.go(AdviceClient.java:20)
at AdviceClient.main(AdviceClient.java:12)


Can anybody tell me where i am going wrong & i have been stuck at this error from 2 days.

Thanks in advance.
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai
For your 2nd solution, u have to update your classpath variable with sever provided jars( it should contains Initialcontextfactory class).

Regards
Kasimurugan R.
 
okkadu privt
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for reply.
But friend i am getting same error, after setting the classpath. Can u explain me the step wise procedure of solving this error. I want to run this first ejb program & proceed futher.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
specify ur jar in .classpath which is generated in eclipse like
<classpathentry kind="lib" path="c:\bea81\user_projects\domains\myjar.jar"

and add this to ur client code
(This is for standalone client ,if u r using jsp/servlet or web appln then no need of this)
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL," t3://localhost:7001";);// or the ip address
initial = new InitialContext(ht);
Object objref = initial.lookup("HomeLookUp");

then lookup the home........

Regards
Kasim
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
the detailed discussion
Here

Amol
 
Anderson gave himself the promotion. So I gave myself this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic