EJB3 说过remote接口 是可以在不同JVM中实现访问的,
也就是说client 是可以在其他的项目中通过JNDI来访问是可以的,
这样的client 为什么在同项目中是可以运行的,放到其他的项目就访问不了,
接口是:HelloWorldRemote
实现类是:HelloWorld
就一个sayHello(String str)方法
jboss5.1.0-jdk6的
请问这是怎么回事,
你们的client又是怎么编写的
也就是说client 是可以在其他的项目中通过JNDI来访问是可以的,
@Test
public void test() throws Exception {
Context ctx = getJBossInitialContext();
//HelloWorldRemote h = (HelloWorldRemote)ctx.lookup("HelloWorld/remote");
System.out.println(ctx.lookup("HelloWorld/remote").getClass().getMethod("sayHello", String.class).invoke(ctx.lookup("HelloWorld/remote"), "456"));
//System.out.println(h.sayHello("我ooo你"));
}
private Context getJBossInitialContext() {
Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
props.setProperty("java.naming.provider.url", "localhost:1099");
Context ctx = null;
try {
ctx = new InitialContext(props);
} catch (NamingException e) {
System.out.println(e.getMessage());
}
return ctx;
}
这样的client 为什么在同项目中是可以运行的,放到其他的项目就访问不了,
接口是:HelloWorldRemote
实现类是:HelloWorld
就一个sayHello(String str)方法
jboss5.1.0-jdk6的
请问这是怎么回事,
你们的client又是怎么编写的