把ejb部署到电脑2上,把客户段部署到电脑1上,当然电脑1只有一个web服务器就足以,然后在客户段程序必须加上电脑2的ip。

解决方案 »

  1.   

    完全可以,EJB就是分布式的,就是一台在美国,另一台在中国都完全可以。
      

  2.   

    EJB本来就是分布式组件啊!只要你实现了远程接口即可!
      

  3.   

    可以,给出一个例子:
     private Context getInitialContext() throws Exception
        {
            //将localhost改成你要访问的机器名字,其它都一样;
            //前提是你要在那台机器上部署;
            String url = "t3://localhost:7001";
            String user = "system";
            String password = "11112163";
            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;
            }
        }
    得到Context后,就可以按标准步骤写了!
      

  4.   

    呵呵,EJB就是拿来干这种活的啊
      

  5.   

    问一下,这里为什么是t3,t3表示什么意思?
    String url = "t3://localhost:7001";