我的create方法为什么没有调用?
还则我 2004-03-27 01:37:11 我的bean是这样的
public abstract class TestCrBean implements SessionBean {
private String strName;
private SessionContext ctx;
public void setSessionContext(SessionContext ctx) {
this.ctx = ctx;
}
public String getName() {
return strName;
}
public void ejbCreate()
throws java.rmi.RemoteException, javax.ejb.CreateException {
this.strName = "kkk";
System.out.print("****************");
}
-----------------------------------------
客户端是这样的
public class MyClient {
private test.xueyk.cr.TestCrHome getHome() throws NamingException {
return (test.xueyk.cr.TestCrHome) getContext().lookup(
test.xueyk.cr.TestCrHome.JNDI_NAME);
}
private InitialContext getContext() throws NamingException {
Hashtable props = new Hashtable();
props.put(
InitialContext.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099");
// This establishes the security for authorization/authentication
// props.put(InitialContext.SECURITY_PRINCIPAL,"username");
// props.put(InitialContext.SECURITY_CREDENTIALS,"password");
InitialContext initialContext = new InitialContext(props);
return initialContext;
}
public void testBean() {
try {
test.xueyk.cr.TestCr myBean = getHome().create();
System.out.println(myBean.getName());
} catch (RemoteException e) {
e.printStackTrace();
} catch (CreateException e) {
e.printStackTrace();
} catch (NamingException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
MyClient test = new MyClient();
test.testBean();
}
}
}
但是执行输出的值是null即create方法没有执行,请高手指点!