I'm trying the example given in the book. I've set all the environment variables according to given on wickedlysmart.com. I'm able to deploy the bean with the help of deployment tool given with the sun development kit. But as I'm trying to run the client program "AdviceClient" it is throwing an exception like this:
C:\Users\Shashi\sonu\projects\advice>java -cp AdviceAppClient.jar;C:\Sun\AppServ er\lib\j2ee.jar;. AdviceClient javax.naming.NoInitialContextException: Need to specify class name in environmen t or system property, or as an applet parameter, or in an application resource f ile: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6 45) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247 ) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav a:284) at javax.naming.InitialContext.lookup(InitialContext.java:351) at AdviceClient.go(AdviceClient.java:15) at AdviceClient.main(AdviceClient.java:9)
please suggest me what to do? Respond me as soon as possible I'm waiting for your answer
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
This exception is thrown if there is no jndi.properties in the classpath of the client (and you don't pass the context related properties to the InitialContext). Each application server has its own values for the context related properties which are specified in the jndi.properties file. For Sun App server, i vaguely remember that the appserv-rt.jar contains the appropriate jndi.properties file. So including the appserv-rt.jar file in the client's classpath should solve this issue.