EJB exception: javax.naming.NoInitialContextException

J

jrefactors

I am new to EJB. I am using WSAD v5.12 to develop EJB project. The
following HelloWorld example is from Mastering EJB book by Ed Ramon.

I got the following run time errors. Please advise. thanks!!


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
at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:652)
at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:255)
at
javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:292)
at javax.naming.InitialContext.lookup(InitialContext.java:359)
at HelloEJBClient.main(HelloEJBClient.java:32)
Exception in thread "main"

=========================================================
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;

public class HelloClient
{
public static void main(String[] args) throws Exception
{
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
Object obj = ctx.lookup("HelloHome");
HelloHome home =
(HelloHome)javax.rmi.PortableRemoteObject.narrow(obj, HelloHome.class);
Hello hello = home.create();
System.out.println(hello.hello());
hello.remove();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top