繁体   English   中英

远程JVM内的远程对象调用

[英]Remote object call inside remote JVM

我正在使用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中本地完成的。

有什么办法可以解决这个问题?

问候,

确保您有用于jndi查找的远程接口(使用批注@Remote)。

您可以看到以下示例: http : //middlewaremagic.com/weblogic/?p=5532 (搜索“ CalculatorBean.java”类)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM