Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoInitialContextException

 
Benjamin Ho
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everybody,
i dont know why NoInitialContextException is occured when a client call a session bean.
The error shown in the following:
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

The following is the source of client:
import javax.naming.Context;
import javax.naming.InitialContext;
import com.oneToMany.person.PersonRemote;
import com.oneToMany.person.PersonRemoteHome;
public class ClientTestPerson {
public static void main(String[] args) {
try{
Context ctx = new InitialContext();
Object ref = ctx.lookup("PersonRemoteHome");
PersonRemoteHome home = (PersonRemoteHome)javax.rmi.PortableRemoteObject.narrow(ref, PersonRemoteHome.class);
PersonRemote person = home.create();
person.setPersonInfo(1, "Yuk", "Lee", "Tom");
System.out.println("Already run client program");
}catch(Exception e){
System.out.println(e);
System.out.println("end of running exception");
}
}
}

Best regards,
Benjamin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic