我正在使用weblogic Server。我想知道在JNDI上下文中绑定一个对象后,是否可以对该对象进行远程调用(在远程JVM中执行它)。
在我本地的JVM中:
Context ctx = null;
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL,"t3://remoteServer:7001/);
env.put(Context.SECURITY_PRINCIPAL,"");
env.put(Context.SECURITY_CREDENTIALS,"");
try {
ctx = new InitialContext(env);
MyObjectImpl obj1 = new MyObjectImpl();
ctx.bind("jndi_name", obj1);
//Now my object can be retrieve from the JNDI context under "jndi_name"
MyObjectImpl obj2 = (MyObjectImpl)ctx.lookup("jndi_name"); //lookup of object
System.out.println(obj2.method(1,2)); //call
}catch (Exception e) {
// a failure occurred
}但是调用是在客户端JVM本地完成的,而不是远程JVM。
有没有办法解决这个问题?
致以敬意,
发布于 2013-12-20 01:13:03
确保您有一个用于jndi查找的远程接口(使用注释@ remote )。
您可以看到这个示例:http://middlewaremagic.com/weblogic/?p=5532 (搜索类“CalculatorBean.java”)。
https://stackoverflow.com/questions/20684143
复制相似问题