File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hep to solve NoInitialContextException error

 
PradeepPillai Pradeep
Ranch Hand
Posts: 186
  • 0
  • 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: 186
  • 0
  • 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...
 
Valentin Tanase
Ranch Hand
Posts: 704
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pradeep,

Did you try this?

http://www.coderanch.com/t/317367/EJB-JEE/java/Running-headfirst-ejb-st-chapter
 
vikas prasad
Ranch Hand
Posts: 44
  • 0
  • 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: 186
  • 0
  • 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: 186
  • 0
  • 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.
 
SL Narasimhan
Greenhorn
Posts: 22
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic