This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes JBoss/WildFly and the fly likes NoInitialContextException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "NoInitialContextException " Watch "NoInitialContextException " New topic


Benjamin Ho

Joined: Nov 19, 2003
Posts: 16
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) {
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("end of running exception");

Best regards,
I agree. Here's the link:
subject: NoInitialContextException
It's not a secret anymore!