你的情况不清楚啊
告诉我们主机名,如下:
       主机1-----EJB
       主机2-----testClient.java
你的testClient.java是用jb之类的IDE生成的吗?若是则必须修改,把代码贴出来

解决方案 »

  1.   

    以下是客户端程序,Ejb已经部署好了,在本机调试用t3://localhost:7001没问题,现在把客户端放在其他机器上,需要做什么修改么?请指教代码如下
    package fourejb;import javax.naming.*;
    import java.util.Properties;
    import javax.rmi.PortableRemoteObject;/**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2003</p>
     * <p>Company: </p>
     * @author not attributable
     * @version 1.0
     */public class Enterprise1TestClient1 extends Object {
      private static final String ERROR_NULL_REMOTE = "Remote interface reference is null.  It must be created by calling one of the Home interface methods first.";
      private static final int MAX_OUTPUT_LINE_LENGTH = 100;
      private boolean logging = true;
      private Enterprise1Home enterprise1Home = null;
      private Enterprise1 enterprise1 = null;  //Construct the EJB test client
      public Enterprise1TestClient1() {
        initialize();
      }  public void initialize() {
        long startTime = 0;
        if (logging) {
          log("Initializing bean access.");
          startTime = System.currentTimeMillis();
        }    try {
          //get naming context
          Context context = getInitialContext();      //look up jndi name
          Object ref = context.lookup("Enterprise1");
          //look up jndi name and cast to Home interface
          enterprise1Home = (Enterprise1Home) PortableRemoteObject.narrow(ref, Enterprise1Home.class);
          if (logging) {
            long endTime = System.currentTimeMillis();
            log("Succeeded initializing local bean access through Local Home interface.");
            log("Execution time: " + (endTime - startTime) + " ms.");
          }
        }
        catch(Exception e) {
          if (logging) {
            log("Failed initializing bean access.");
          }
          e.printStackTrace();
        }
      }  private Context getInitialContext() throws Exception {
        String url = "t3://yuanb: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;
        }
      }  //----------------------------------------------------------------------------
      // Methods that use Home interface methods to generate a Remote interface reference
      //----------------------------------------------------------------------------  public Enterprise1 create() {
        long startTime = 0;
        if (logging) {
          log("Calling create()");
          startTime = System.currentTimeMillis();
        }
        try {
          enterprise1 = enterprise1Home.create();
          if (logging) {
            long endTime = System.currentTimeMillis();
            log("Succeeded: create()");
            log("Execution time: " + (endTime - startTime) + " ms.");
          }
        }
        catch(Exception e) {
          if (logging) {
            log("Failed: create()");
          }
          e.printStackTrace();
        }    if (logging) {
          log("Return value from create(): " + enterprise1 + ".");
        }
        return enterprise1;
      }  public void executeRemoteCallsWithDefaultArguments() {
        if (enterprise1 == null) {
          System.out.println("Error in executeRemoteCallsWithDefaultArguments(): " + ERROR_NULL_REMOTE);
          return ;
        }
      }  //----------------------------------------------------------------------------
      // Utility Methods
      //----------------------------------------------------------------------------  private void log(String message) {
        if (message == null) {
          System.out.println("-- null");
          return ;
        }
        if (message.length() > MAX_OUTPUT_LINE_LENGTH) {
          System.out.println("-- " + message.substring(0, MAX_OUTPUT_LINE_LENGTH) + " ...");
        }
        else {
          System.out.println("-- " + message);
        }
      }
      //Main method  public static void main(String[] args) {
        Enterprise1TestClient1 client = new Enterprise1TestClient1();
        // Use the client object to call one of the Home interface wrappers
        // above, to create a Remote interface reference to the bean.
        // If the return value is of the Remote interface type, you can use it
        // to access the remote interface methods.  You can also just use the
        // client object to call the Remote interface wrappers.
      }
    }
      

  2.   

    这个测试用例是jbuilder自动生成的我看人家程序就是把
    properties.put(Context.PROVIDER_URL,url);中的url改为服务器的地址,另外iiop和t3的区别也请不吝赐教
      

  3.   

    客户端的private Context getInitialContext() 报错:
    你确定,你发布EJB的机器主机名是yuanb吗?
    并且发布EJB的机器主机已经将服务startup了吗?
    试一试将t3://yuanb:7001改为相应的IP地址:如t3://192.168.0.10:7001
      

  4.   

    在本机上运行无论用机器名,ip还是localhost均调用的是localhome但是localhome这个东西要求是在同一jvm上的,因此现在需要去调用home而不是localhome,高手们说我的理解对不对啊?但是怎么去设置客户端的访问方式呢?请做过此类问题的高手指导一把~~谢谢了~
      

  5.   

    从enterprise1 = enterprise1Home.create()看你调用的是home ,而不是localhome
      

  6.   

    调用的是home应该没问题啊?你能不能做个例子发我邮箱里面?jb8+weblogic谢谢
      

  7.   

    好了,问题is over,那家伙部署的时候有问题,我写了个新的就没问题了,谢谢酷马,分给你了
      

  8.   

    已经给你发了一个例子,使用了weblogic7+jb8
      

  9.   

    能把例子也发我一个么?学习
    thanks
    [email protected]