• Post Reply Bookmark Topic Watch Topic
  • New Topic

error while running sample EJB

 
bharat kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to EJB, and trying to to run the sample EJB which returns the test message. I am using Sun application server as an EJB Server, at server side everything is o.k, i am able to deploy the EJB, but when i try to run the client i am getting the following errors
Client Code :
IntialConetext initContext = new InitialContext();
String jndiname = "java:comp/env/ejb/AdviceBean"; // "AdviceBean";
Object objref = initContext.lookup(jndiname);
when i run the client i get the following exception :
D:\projects\headfirst\advice>java -classpath . AdviceClient
exception : javax.naming.NoInitialContextException: Need to specify class name in environment or system property: java.naming.factory.initial
So i tried to add the context propeties like
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtxFactory"); //env.put(Context.PROVIDER_URL, "http://localhost:3641");InitialContext
IntialConetext initContext = new InitialContext(env);
String jndiname = "java:comp/env/ejb/AdviceBean"; // "AdviceBean";
Object objref = initContext.lookup(jndiname);
When i run like this i am getting this error :
D:\projects\headfirst\advice>java -classpath . AdviceClient
exception : javax.naming.ConfigurationException: http://localhost:3641 does not
contain an IOR
i think the error is due to jndi only,
can anyone suggest me what is the problem.
thanks in advance,
Bharat
[ December 30, 2003: Message edited by: bharat kumar ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!