Hashtable prop = new Hashtable();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
prop.put(Context.PROVIDER_URL, "corbaloc:iiop:10.39.100.250:2809");
InitialContext it = new InitialContext(prop);
String jdni = "Session/DateProcess";
System.out.println("..........call ejb......");
Object object = it.lookup(jdni);
com.fly.test.ejb.DateProcessHome dpHome =
(com.fly.test.ejb.DateProcessHome) javax.rmi.PortableRemoteObject.narrow(object, com.fly.test.ejb.DateProcessHome.class);
com.fly.test.ejb.DateProcess dp = dpHome.create();
dp.process(1);
System.out.println("..........call ejb .....over.");

解决方案 »

  1.   

    我的服务器是jboss,还有ClientUtil中已经有这些调用Home 的语句了.如下面的语句:
    private static Object lookupHome(java.util.Hashtable environment, String jndiName, Class narrowTo) throws javax.naming.NamingException {
          // Obtain initial context
          javax.naming.InitialContext initialContext = new javax.naming.InitialContext(environment);
          try {
             Object objRef = initialContext.lookup(jndiName);
             // only narrow if necessary
             if (narrowTo.isInstance(java.rmi.Remote.class))
                return javax.rmi.PortableRemoteObject.narrow(objRef, narrowTo);
             else
                return objRef;
          } finally {
             initialContext.close();
          }
       }
    这些都是myeclipse自动生成的.我调用这句时就出错了.