你需要设置这些参数,在应用服务器中这个已经作为系统属性了,所以直接获取就可以
而在客户机上就不一定设置了,所以你必须设置
      prop.put(Context.INITIAL_CONTEXT_FACTORY,
               "org.jnp.interfaces.NamingContextFactory");
      prop.put(Context.PROVIDER_URL,"iiop://yourhostname/");Context.INITIAL_CONTEXT_FACTORY根据你实际配置设置,我给了一个我自己的例子

解决方案 »

  1.   

    嗬嗬,找不到JNDI驱动“org.jnp.interfaces.NamingContextFactory”,你把websphere的那个包加在classpath中就可以了。
      

  2.   

    web端要加那些包才可以调用ejb呢?
      

  3.   

    to:tanghuan() :
    jb生成是下面的代码,我应该怎样改呢???  private Context getInitialContext() throws NamingException
      {
        Hashtable environment = new Hashtable();
        environment.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
        environment.put(Context.PROVIDER_URL, "corbaloc:iiop:192.168.0.101:2809");
        environment.put(Context.URL_PKG_PREFIXES, "com.ibm.ws.naming");
        return new InitialContext(environment);
      }
      

  4.   

    可建个jndi.properties放在classpath下,或按上面的方法做也可