[table]
|我在运行一个EJB客户端代码总是出这个错: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:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at cn.itcast.test.EJBClient.main(EJBClient.java:20)|
[/table]
这就是我mian 方法中的代码,InitialContext ctx=new InitialContext();
HelloWorld helloworld=(HelloWorld) tx.lookup "HelloWorldBean/remote");
System.out.println(helloworld.sayHello("小明"));
这个错误的原因是:
我在jndi.properties文件里写错了,经修改后:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost\:1099
成功!
|我在运行一个EJB客户端代码总是出这个错: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:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at cn.itcast.test.EJBClient.main(EJBClient.java:20)|
[/table]
这就是我mian 方法中的代码,InitialContext ctx=new InitialContext();
HelloWorld helloworld=(HelloWorld) tx.lookup "HelloWorldBean/remote");
System.out.println(helloworld.sayHello("小明"));
这个错误的原因是:
我在jndi.properties文件里写错了,经修改后:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost\:1099
成功!