答1、在另外一台机子上配置jdk+j2ee.jar就可以了,调用方法和在同一台机子上一样,只用修改其中调用的地址,如t3://192.168.9.88:7001。
答2、无论在哪里都可以调用到你的ejb,根据jb给你自动生成的代码,修改一下,在jsp、servlet都可以调用到的。
答3、对接线我没有试过,你试试看,结果贴出来。网上的ip是可以的。安全性weblogic自己考虑到了。

解决方案 »

  1.   

    1.weblogic8当然不用装了,用你这台作应用服务器就可
    2.一般用servlet测试
    3.用网上的IP地址吧public class TestEJB extends HttpServlet  {
        public void doGet(HttpServletRequest request, HttpServletResponse   response) throws ServletException, IOException {
        try{
            Context ct=new InitialContext();
            Object obj=ctx.lookup("ejbJNDIName");
            EJBHome home=(EJBHome)javax.rmi.PortableRemoteObject(obj,EJBHome.class);
            EJBRemote ejbRemote=home.create();//EJBRemote为你的ejb的远程接口
            ejbRemote.***();//你在ejb定义的方法
            ...
        }catch(Exception e){
        }
        }
    }
      

  2.   

    http://expert.csdn.net/Expert/TopicView1.asp?id=2352546
      

  3.   

    import test.ejb.*;
    import javax.naming.*;
    import java.util.Properties;
    import javax.rmi.PortableRemoteObject;public class TestClient
    {
      public TestClient()
      {
        
        try
        {
          Context ctx = getInitialContext();
          Object ref = ctx.lookup("test.ejb.HsiSessionHome");
          //HsiSessionHome testHome = (HsiSessionHome) PortableRemoteObject.narrow(ref, HsiSessionHome.class);  
          //HsiSession test=testHome.create();
          HsiSession test=(HsiSessionHome)ref.create();
          test.create("9","7","7");
        }
        catch(Exception e)
        {
          
          e.printStackTrace();
        }
      }  private Context getInitialContext()
      {
        String url = "t3://localhost: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);
          }
          //Properties pops=System.getProperties();
          return new InitialContext(properties);
        }
        catch(Exception e)
        {
          e.printStackTrace();
        }
        return null;
      }
      
      public static void main(String[] args)
      {
        TestClient client = new TestClient();
      }
    }
      

  4.   

    谢谢楼上两位大哥!
    1,回: adijava(以前甭提了,以后非加油不可!) 
        在另外一台机子上配置jdk+j2ee.jar就可以了,我要调用的机子装有jdk1.4,
        对了j2ee.jar要怎么安装呀,怎么用呀?在jdk+j2ee.jar就可以写servlet吗?
        还是写应用程序呀:
       public static void main(String[] args) {
              try {
                  bean1TestClient1 client = new bean1TestClient1();
                  bean1 remote=client.create();
                  System.out.print(remote.helloworld("Demo one"));
              }catch (RemoteException ex) {
                  ex.printStackTrace();
              }
       }
    如果我要用如上的程序,要怎么修改?
    有人说要将remote接口和home接口的.java文件靠到工程文件source目录下,然后import要用的ejb包,这个需要吗?
    回 inprise_lyj(只愛一點點):
       我没用过servelt(不好意思,呵呵~~~),servlet在jdk下可以编吗?
       不过你可的程序很像应用程序下的呀?
      

  5.   

    各位大哥:
    原来和本机调用差不多呀,我本来是用jbuider生成的程序,
    我刚才自己新建一个项目,一直提示:
    "bean1Home.java": Package D:\Documents and Settings\star\jbproject\bb\src\bb\bean1Home.java stated in source aa does not match directory D:\Documents and Settings\star\jbproject\bb\src\bb\bean1Home.java. at line 1, column 9是不是要将remote接口和home接口的.java文件靠到工程文件source目录下,然后import要用的ejb包,这个需要吗?
    我打算在用jdk下直接编,请问环境变量要不要变,我只有设jdk的变量,
    在jdk下还要再装什么吗?比如j2ee.jar吗?
    用jbuider编好像好多问题哦,除了直接用它的testclient!
      

  6.   

    已经在部署好一个名叫ejb2的EJB,文件是ejb2.jar,现在写一个client来调用,但是无论如何都通不过编译,因为找不到home,remote的定义。我要怎么办呢?
    把home和remote接口拷到我的测试目录下还是不行,
    然后我想import要用的ejb包,比如说在d:\j\ejb2.jar
    要怎么import呢,import d:\j\ejb2 这样不行的?