试一试吧,记得先将JBuilder6和WebLogic6。1配置好呀。
而且你写得EJB确保在Weblogic上已经正确发布了。
Good Luck!
package product;import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import java.util.*;public class Client
{
   public static void main(String[] arsgs)
   {
      private ProductHome home=null;//Home接口
      private Product remote = null;//Remote接口      //如果你调用的不是本地上的EJB,则如,url = "t3://192.168.0.88:7001"; 根据你的WebLogic的配置给以变动     
      String url = "t3://localhost:7001";      try
      {
         Context ctx=getInitialContext(url);         Object ref = ctx.lookup("Product");         home=(ProductHome)PortableRemoteObject.narrow(ref, ProductHome.class);         remote  = home.create();
      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
   }   public Context getInitialContext(String url) throws Exception {
    //String url = "t3://192.168.0.88:7001";
    String user = null;
    String password = null;
    Properties properties = null;
    try {
      properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      properties.put(Context.PROVIDER_URL, url);
      if (user != null) {
        properties.put(Context.SECURITY_PRINCIPAL, user);
        properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
      }      return new InitialContext(properties);
    }
    catch(Exception e) {
      log("Unable to connect to WebLogic server at " + url);
      log("Please make sure that the server is running.");
      throw e;
    }
}

解决方案 »

  1.   

    JBuilder6和WebLogic6。1配置好的,我都做过很多EJB了,唯独最后这个CMP的过不了啊,你说的这个方法,我前不久用过,不行的
      

  2.   

    你有jb吗?有的话,很简单啊,用jb自己带的客户端测试工具就行了。
    jbuilder(5,6)->file->new->enterprise->ejb test client,然后根据向导进行,最后一般在程序中,加上自己调用的函数,比方来个打印什么的,这就是最简单的模式了。
    一般来说,很简单,你可以参考上面的程序,刚开始的话,可以什么都不要,加上
    try
          {
             Context ctx=getInitialContext(url);         Object ref = ctx.lookup("Product");         home=(ProductHome)PortableRemoteObject.narrow(ref, ProductHome.class);         remote接口 remote1  = home.create();
           //调用自己的函数,也就是所谓的商业方法。
             remote1.自己的函数();
             
          }
    就可以了
      

  3.   

    EJB的代码是你自己写的吗?
    若是引用别人目录下的文件,则在使用EJB的客户端的Wizards时,有一些问题要注意的。 不过,你把对EJB的错误调用改拉后还不行吗?有什么错误?
      

  4.   

    用Wizards很简单的,不应该有什么错误啊,除非你的EJB有问题。
      

  5.   

    你的程序是JB生成的吧. 它不能直接在命令行下运行的,它必须在你的应用服务器里才能运行的.关键就在这一句:
    Context ctx=new InitialContext();
    这一句是通过环境来寻找相对应的Context的. 
    你换成arke(keke)说的就行了!