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

Hep to solve NoInitialContextException error

 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing an example from HF. I think I followed the instructions exactly as it is from HF. But I am not able to run the program. I am getting the following error:

C:\projects\advice>java AdviceClient
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(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:15)
at AdviceClient.main(AdviceClient.java:9)


My JNDI name and the name in the context lookup are the same. Any help is greately appreciated.
Thanks.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am in a deadlock. I cannot go anywhere unless somebody help me.
Please...
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pradeep,

Did you try this?

https://coderanch.com/t/317367/EJB-JEE/java/Running-headfirst-ejb-st-chapter
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pradeep,
I will sugest you to check your path,
See all this problem have a root cause with the path varible you set.
if you tell how have you set class paths then i can try to help.
still

try this: SET ENVIRONMENT VARIABLES:
JAVA_HOME C:\jdk1.3.1_16
J2EE_HOME C:\j2sdkee1.3.1
CLASSPATH C:\j2sdkee1.3.1\lib\j2ee.jar;D:\Certification\projects\advice

CLASSPATH should contain your j2ee jar file as well as your application jar file.
just put directory path for AdviceAppClient.jar file ok.
and follow the instruction in the book.
$ javac -classpath %CLASSPATH%;AdviceAppClient.jar AdviceClient.java

$ java -cp %CLASSPATH%;AdviceAppClient.jar AdviceClient
Bingo
This is what I did and it works fine may be you can try the same.
vikas prasad
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following in the env variable.
JAVA_HOME=C:\j2sdk1.4.2_06
CLASSPATH=C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar;C:\Program Files\Altova\xmlspy\XMLSpyInterface.jar

When I execute the command to run,I specify the classpath in the command.
C:\projects\advice>java -cp .;C:\Sun\AppServer\lib\j2ee.jar;AdviceAppClient.jar AdviceClient

Do I still have to set my environment variables?

I don't have a J2EE_HOME environment variable. Where is it pointing to?

I get the error only when I run. I can compile.

Thank you very much.
[ November 28, 2005: Message edited by: PradeepPillai Pradeep ]
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My environment variables are set now.

CLASSPATH=C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar;C:\Program Files\Altova\xmlspy\XMLSpyInterface.jar
J2EE_HOME=C:\j2sdkee1.3
JAVA_HOME=C:\j2sdk1.4.2_06

I still get the same error. For other classpath dependencies I point to the right location with -cp as shown in the previous post.
 
Greenhorn
Posts: 22
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even I faced a similar problem. I just added appserv-rt.jar to my classpath while running the application and everything went on fine.

Cheers,
Narasimhan
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic