下面是我的测试类类
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
Context enc;
try {
enc = new InitialContext(env);
// HelloBeanRemote remote = (HelloBeanRemote) enc.lookup("HelloBean/remote");
HelloBeanLocal local = (HelloBeanLocal) enc.lookup("HelloBean/local");
// System.out.println(remote.toString());
// System.out.println(remote.sayHello()); //远程调用可以成功
if(local==null){ //为什么这是false
System.out.println("local null");
}else{
System.out.println(local.toString());//这一行提示空指针
}
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
Context enc;
try {
enc = new InitialContext(env);
// HelloBeanRemote remote = (HelloBeanRemote) enc.lookup("HelloBean/remote");
HelloBeanLocal local = (HelloBeanLocal) enc.lookup("HelloBean/local");
// System.out.println(remote.toString());
// System.out.println(remote.sayHello()); //远程调用可以成功
if(local==null){ //为什么这是false
System.out.println("local null");
}else{
System.out.println(local.toString());//这一行提示空指针
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货