/**
   * 在JNDI树中寻找EJB主接口
   */
  private TraderHome lookupHome() throws NamingException
  {
    // 使用JNDI寻找EJB
    Context ctx = getInitialContext();
   
    try {
      Object home = ctx.lookup(JNDI_NAME);
      return (TraderHome) narrow(home, TraderHome.class);
    } catch (NamingException ne) {
     //异常处理
      log("The client was unable to lookup the EJBHome.  Please make sure ");
      log("that you have deployed the ejb with the JNDI name "+JNDI_NAME+" on the WebLogic server at "+url);
      throw ne;
    }
  }
我想是上面的哪个地方有毛病吧。
谁来指正一下。

解决方案 »

  1.   

    你的EJB没有指定服务器吧,pls check。
      

  2.   

    服务器?
    weblogic server 6.1 
    我是照书做的啊。
      

  3.   

    应该是没有发布成功,或者你发布的JNDI名字不是你这个
    你可以现在weblogic server的console控制台上看看这个EJB的状态,
    以及看看JNDI树是否正确
      

  4.   

    要指定target为某个服务器,另外,注意创建Context时指定一些必要的属性,weblogic的例子写得很明确
      

  5.   

    给你提个性:
    1、Context ctx = getInitialContext();
       里面注意要把url和factory加进去,你的好像是加了,但是不知道是否正确!
    2、检查你在client里定义的jndi名字是否和你deplay ejb里面的配置文件一致!
      

  6.   

    jar cv0f std_ejb_basic_statelessSession.jar META-INF examplesjava weblogic.ejbc -compiler javac build\std_ejb_basic_statelessSession.jar c:\bea\wlserever6.1\config\mydomain\applications\ejb_basic_statelessSession.jar通过这两个代码已经在c:\bea\wlserever6.1\config\mydomain\applications\里生成一个WEBLOGIC所识别的包。是这么个过程啊。
      

  7.   

    回JAVA无罪,我有罪:
    /**
       * 使用属性对象获取JNDI服务上下文
       */
      private Context getInitialContext() throws NamingException {
        
        try {
          // 声明属性对象
          Properties h = new Properties();
          h.put(Context.INITIAL_CONTEXT_FACTORY,
            "weblogic.jndi.WLInitialContextFactory");
          h.put(Context.PROVIDER_URL, url);
          //返回的特定属性的上下文对象
          return new InitialContext(h);
        } catch (NamingException ne) {
         //异常处理
          log("We were unable to get a connection to the WebLogic server at "+url);
          log("Please make sure that the server is running.");
          throw ne;
        }
      }
    上面这段代码不就是么。
      

  8.   

    我认为你是没有发布成功。请你到weblogic看看jndi tree里有没有:JNDI_NAME
      

  9.   

    当前问题解决了。是在WEBLOGIC里的配置有问题。不过,对JNDI还是模糊。这里要重点感谢 米、华仔。谢谢……