Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Naming Exception at runtime when running client.

 
dimpsonu arora
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naming Exception caught: 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
--------Client Code-------------
import javax.ejb.*;
import hello.*;
import java.util.*;
import javax.naming.InitialContext;
class helloClient
{
public static void main(String args[])
{
try
{
InitialContext ctx = new InitialContext();
Object objRef=ctx.lookup("HelloEJB");
HelloHome home=(HelloHome)javax.rmi.PortableRemoteObject.narrow(objRef, HelloHome.class);
HelloSonu bean=home.create();
System.out.println("Monthly net Salary: "+bean.sayHello());
}
catch(javax.naming.NamingException ne)
{
System.out.println("Naming Exception caught: " +ne);
}
catch(javax.ejb.CreateException ce)
{
System.out.println("Create Exception caught: " +ce);
}
catch(java.rmi.RemoteException re)
{
System.out.println("Remote Exception caught: " +re);
}
}
}
-------------Please help--------Using j2ee server---------
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to provide certain configuration properties to the constructor of InitialContext. Search this forum and you'll find plenty of examples.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic