Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting error from AdviceClient code from Head First EJB book, pg 57

 
Martin Brice
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to compile and then run the code for AdviceClient.java from page 57, and I'm getting the following error when I goto run the code.
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet pa
rameter, 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:19)
at AdviceClient.main(AdviceClient.java:10)
I'm using the following two lines to compile and then run it.
D:\Ejbs\advice>javac -classpath .\classes;d:\j2sdkee1.3.1\lib\j2ee.jar AdviceClient.java
D:\Ejbs\advice>java AdviceClient
What is going on here?
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Martin Brice:
I'm trying to compile and then run the code for AdviceClient.java from page 57, and I'm getting the following error when I goto run the code.
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet pa
rameter, 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:19)
at AdviceClient.main(AdviceClient.java:10)
I'm using the following two lines to compile and then run it.
D:\Ejbs\advice>javac -classpath .\classes;d:\j2sdkee1.3.1\lib\j2ee.jar AdviceClient.java
D:\Ejbs\advice>java AdviceClient
What is going on here?

Make sure that environment variables are correctly configured.
http://www.wickedlysmart.com/HeadFirst/HeadFirstEJB/HeadFirstEJBNotes.html
Include j2ee.jar in classpath,use the following command to compile
javac -classpath %CLASSPATH%;AdviceAppClient.jar AdviceClient.java
Use following command to run
java -cp %CLASSPATH%;AdviceAppClient.jar AdviceClient
Veena
 
Martin Brice
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just about to try this out tonight. Thank you for the reply.
 
Frederic Filiatrault
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !

I'm having the same problem. Anyone have an idea ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic