jboss下定义好 session bean 后,
如果直接 在client 中写如下代码 可以调用MyBeanRemote.doSomething()执行出结果
Properties p = new Properties() ;
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory") ;
p.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces") ;
p.put(Context.PROVIDER_URL, "localhost") ; 
InitialContext ctx = new InitialContext(p); 
MyBeanRemote bean = ( MyBeanRemote) ctx.lookup("MyBean/remote"); 
bean.doSomething();  //运行的结果
但是如果通过 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
 在client 中写 代码:
Context jndiContext = new javax.naming.InitialContext();
Object ref = jndiContext.lookup("MyBean/remote");
TravelAgentRemote bean= (TravelAgentRemote)
PortableRemoteObject.narrow(ref,TravelAgentRemote.class);
bean.doSomething();  报错:
javax.naming.NoInitialContextException: Need to specify class name in environmen
t or system property, or as an applet parameter, or in an application resource f
ile:  java.naming.factory.initial这是为什么?jndi.properties 是自动被识别的吗?谢谢大家!