我自己知道是什么原因了~~~哈哈

解决方案 »

  1.   


    package chapter11; 
    import java.rmi.*; 
    import javax.naming.*; import java.util.*; 
    public class SimpleServer { 
    static Context namingContext = null; 
    public static void bind(String name,HelloService object){ 
    Hashtable ht = new Hashtable(); 
    ht.put(Context.INITIAL_CONTEXT_FACTORY, 
    "weblogic.jndi.WLInitialContextFactory"); 
    ht.put(Context.PROVIDER_URL, "t3://localhost:7001"); try{ 
    namingContext = new InitialContext(ht); 
    namingContext.rebind(name,object); 
    }catch(NamingException e){ 
    e.printStackTrace(); 
    }finally{ 
    try{ 
    namingContext.close(); 
    }catch(Exception e){ 
    e.printStackTrace(); 



    public static void main(String args[]){ 
    try{ 
    HelloService service1 = new HelloServiceImpl("service1"); 
    HelloService service2 = new HelloServiceImpl("service2"); bind("HelloService1",service1); 
    bind("HelloService2",service2); System.out.println("the server has registered two HelloService Object"); 
    }catch(Exception e){ 
    e.printStackTrace(); 



    问题出在以下地方
    bind("rmi://localhost:7001/HelloService1",service1); 
    bind("rmi://localhost:7001/HelloService2",service2); 
    当不使用rmiregistry,使用weblogic或Jboss时候不需要指定rmi、地址和端口,因为之前的用InitialContext已指定定好了。
    -------
    没想到两个月的复杂中自己想到了原因,哈哈