//Client code that invokes methods on simple stateless session bean. public class HelloClient {
public static void main (String [] args) { try { System.out.println("Client Running"); //Get a naming context InitialContext jndiContext = new InitialContext(); System.out.println("Got Context");
//Get a reference to the HelloBean Object ref = jndiContext.lookup("hello\Hello"); System.out.println("Got Reference");
//Get a reference from this to the bean's Home interface HelloHome home = (HelloHome)PortableRemoteObject.narrow(ref, HelloHome.class);
//Create a Hello object from the Home interface Hello hello = home.create();
//Call the hello() method, and print it System.out.println(hello.hello());
//Done with EJB object, so remove it hello.remove();
} catch (Exception e) { System.out.println(e.toString()); e.printStackTrace(); } } When I run the client I am getting the following error message Client Running Got Context 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 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:643) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:283) at javax.naming.InitialContext.lookup(InitialContext.java:350) at helloworld.HelloClient.main(HelloClient.java:27) Process Exit... I have a jndi.properties file as follows and I have added this file to my classpath. java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.provider.url=localhost:1099 java.naming.factory.url.pkgs=org.jboss.naming rg.jnp.interfaces In addition, I have the jboss-j2ee.jar file in my classpath. Would greatly appreciate any assistance on the above. Regards Monica
Adam Hardy
Ranch Hand
Joined: Oct 09, 2001
Posts: 563
posted
0
when you create the InitialContext, don't you have to tell it which class to use like so:
not that i'm an expert with this, in fact i never got it to work
I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.