当前页面: 开发资料首页 → J2EE 专题 → 在线等:为何我的客户端EJBHome返回为空!~? 
在线等:为何我的客户端EJBHome返回为空!~? 
摘要: 在线等:为何我的客户端EJBHome返回为空!~?  
我用NetBean创建了一个EJB模块(无态,创建远程接口),然后用其Add Bussiness...添加了一个方法Hello()返回String  "hello,EJB",然后在该项目内部该包里面创建客户端程序,很简单一个框架,先用PortableRemoteObject返回出EJBHome,然后获取HelloRemote(这个是EJBObject),可是EJBHome就是返回空,我用的是Sun Application Server 9,采用的是缺省配置,怎么也搞不定,有人帮帮我吗?
客户端代码:
/*
 * HelloClient.java
 *
 * Created on 2006年9月11日, 下午7:43
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package examples;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
public class HelloClient {    
    public static void main (String[] args) throws Exception
    {
        Hashtable tbl = new Hashtable();
        tbl.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
        tbl.put(Context.PROVIDER_URL, "iiop://localhost:3700");
        InitialContext ctx = new InitialContext(tbl);
        Object obj = ctx.lookup("ejb/HelloBean");
        HelloRemoteHome rmtHome = (HelloRemoteHome) PortableRemoteObject.narrow(obj, HelloRemoteHome.class);
        HelloRemote rmt = rmtHome.create();        
        System.out.println(rmt.Hello());
    }    
}
HelloRemoteHome rmtHome = (HelloRemoteHome) PortableRemoteObject.narrow(obj, HelloRemoteHome.class);
就是这里rmtHome为空,怎么回事情
JBOSS + Eclipse