CORBA + JAVA+动态客户端 - Request 对象的 invoke() 方法失败

发布于 2024-10-31 05:31:39 字数 7271 浏览 1 评论 0原文

我有一个非常简单的 IDL 文件:

module tests{

  interface test {
    boolean isEquals(in any num1, in any num2);
  };
};

使用 idlj 后,我编写了整个应用程序(分为服务器/仆人/客户端)并且工作正常。我现在唯一的问题是,当我尝试重写客户端以便它可以使用动态调用时,Requst 对象的 ivoke() 方法失败。

客户端的代码:

ORB orb = ORB.init(args, null);

org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");

NamingContext ncRef = NamingContextHelper.narrow(objRef);
NameComponent nc = new NameComponent("testDynamic", "");
NameComponent[] path = {nc};
//Object objectRef = ncRef.resolve(path);
test objectRef = testHelper.narrow(ncRef.resolve(path));

(...)

Any any1 = orb.create_any();
Any any2 = orb.create_any();

NVList arglist = orb.create_list(2);
any1.insert_char('c');
any2.insert_char('d');
NamedValue nvArg = arglist.add_value("any1", any1, org.omg.CORBA.ARG_IN.value);
NamedValue nvArg2 = arglist.add_value("any2", any2, org.omg.CORBA.ARG_IN.value);

// create return value
Any result = orb.create_any();
// insert dummy value
result.insert_boolean(false);
NamedValue resultVal = orb.create_named_value("result", result, 
    org.omg.CORBA.ARG_OUT.value);

// create request
Request req = objectRef._create_request(null, "isEquals", arglist, resultVal);
req.invoke();

运行客户端会导致错误,其中 req.invoke() 是一个可疑的地方:(

错误日志中的最后一行是 at server.TestClient.main (TestClient.java:75),这是 req.invoke() 方法)

Error: org.omg.CORBA.MARSHAL: ----------BEGIN server-side stack trace----------
org.omg.CORBA.MARSHAL:   vmcid: SUN  minor code: 207  completed: No
    at com.sun.corba.se.impl.logging.ORBUtilSystemException.endOfStream(Unknown Source)
    at com.sun.corba.se.impl.logging.ORBUtilSystemException.endOfStream(Unknown Source)
    at com.sun.corba.se.impl.encoding.BufferManagerReadStream.underflow(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_1.grow(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_2.alignAndCheck(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_long(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream.read_long(Unknown Source)
    at com.sun.corba.se.impl.encoding.WrapperInputStream.read_long(Unknown Source)
    at com.sun.corba.se.impl.corba.TypeCodeImpl.read_value_kind(Unknown Source)
    at com.sun.corba.se.impl.corba.TypeCodeImpl.read_value(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_any(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream.read_any(Unknown Source)
    at tests.testPOA._invoke(testPOA.java:36)
    at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleInput(Unknown Source)
    at com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(Unknown Source)
    at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.dispatch(Unknown Source)
    at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.doWork(Unknown Source)
    at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.performWork(Unknown Source)
    at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(Unknown Source)

----------END server-side stack trace----------  vmcid: SUN  minor code: 207  completed: No
org.omg.CORBA.MARSHAL: ----------BEGIN server-side stack trace----------
org.omg.CORBA.MARSHAL:   vmcid: SUN  minor code: 207  completed: No
    at com.sun.corba.se.impl.logging.ORBUtilSystemException.endOfStream(Unknown Source)
    at com.sun.corba.se.impl.logging.ORBUtilSystemException.endOfStream(Unknown Source)
    at com.sun.corba.se.impl.encoding.BufferManagerReadStream.underflow(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_1.grow(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_2.alignAndCheck(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_long(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream.read_long(Unknown Source)
    at com.sun.corba.se.impl.encoding.WrapperInputStream.read_long(Unknown Source)
    at com.sun.corba.se.impl.corba.TypeCodeImpl.read_value_kind(Unknown Source)
    at com.sun.corba.se.impl.corba.TypeCodeImpl.read_value(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_any(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream.read_any(Unknown Source)
    at tests.testPOA._invoke(testPOA.java:36)
    at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleInput(Unknown Source)
    at com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(Unknown Source)
    at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.dispatch(Unknown Source)
    at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.doWork(Unknown Source)
    at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.performWork(Unknown Source)
    at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(Unknown Source)

----------END server-side stack trace----------  vmcid: SUN  minor code: 207  completed: No
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase.getSystemException(Unknown Source)
    at com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage_1_2.getSystemException(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.getSystemExceptionReply(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(Unknown Source)
    at com.sun.corba.se.impl.corba.RequestImpl.doInvocation(Unknown Source)
    at com.sun.corba.se.impl.corba.RequestImpl.invoke(Unknown Source)
    at server.TestClient.main(TestClient.java:75)

我可以请求一点帮助吗? 谢谢。

I have a very simple IDL file:

module tests{

  interface test {
    boolean isEquals(in any num1, in any num2);
  };
};

After using idlj, I had written the whole application (divided into server / servant / client) and it works ok. My only problem right now is that when I try to rewrite the client, so it could use the dynamic invocation, the ivoke() method of the Requst object fails.

The code for the client:

ORB orb = ORB.init(args, null);

org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");

NamingContext ncRef = NamingContextHelper.narrow(objRef);
NameComponent nc = new NameComponent("testDynamic", "");
NameComponent[] path = {nc};
//Object objectRef = ncRef.resolve(path);
test objectRef = testHelper.narrow(ncRef.resolve(path));

(...)

Any any1 = orb.create_any();
Any any2 = orb.create_any();

NVList arglist = orb.create_list(2);
any1.insert_char('c');
any2.insert_char('d');
NamedValue nvArg = arglist.add_value("any1", any1, org.omg.CORBA.ARG_IN.value);
NamedValue nvArg2 = arglist.add_value("any2", any2, org.omg.CORBA.ARG_IN.value);

// create return value
Any result = orb.create_any();
// insert dummy value
result.insert_boolean(false);
NamedValue resultVal = orb.create_named_value("result", result, 
    org.omg.CORBA.ARG_OUT.value);

// create request
Request req = objectRef._create_request(null, "isEquals", arglist, resultVal);
req.invoke();

Running the client leads to an error, with the req.invoke() beeing an suspect:

(the last line in the error log is at server.TestClient.main(TestClient.java:75), which is the req.invoke() method)

Error: org.omg.CORBA.MARSHAL: ----------BEGIN server-side stack trace----------
org.omg.CORBA.MARSHAL:   vmcid: SUN  minor code: 207  completed: No
    at com.sun.corba.se.impl.logging.ORBUtilSystemException.endOfStream(Unknown Source)
    at com.sun.corba.se.impl.logging.ORBUtilSystemException.endOfStream(Unknown Source)
    at com.sun.corba.se.impl.encoding.BufferManagerReadStream.underflow(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_1.grow(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_2.alignAndCheck(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_long(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream.read_long(Unknown Source)
    at com.sun.corba.se.impl.encoding.WrapperInputStream.read_long(Unknown Source)
    at com.sun.corba.se.impl.corba.TypeCodeImpl.read_value_kind(Unknown Source)
    at com.sun.corba.se.impl.corba.TypeCodeImpl.read_value(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_any(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream.read_any(Unknown Source)
    at tests.testPOA._invoke(testPOA.java:36)
    at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleInput(Unknown Source)
    at com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(Unknown Source)
    at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.dispatch(Unknown Source)
    at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.doWork(Unknown Source)
    at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.performWork(Unknown Source)
    at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(Unknown Source)

----------END server-side stack trace----------  vmcid: SUN  minor code: 207  completed: No
org.omg.CORBA.MARSHAL: ----------BEGIN server-side stack trace----------
org.omg.CORBA.MARSHAL:   vmcid: SUN  minor code: 207  completed: No
    at com.sun.corba.se.impl.logging.ORBUtilSystemException.endOfStream(Unknown Source)
    at com.sun.corba.se.impl.logging.ORBUtilSystemException.endOfStream(Unknown Source)
    at com.sun.corba.se.impl.encoding.BufferManagerReadStream.underflow(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_1.grow(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_2.alignAndCheck(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_long(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream.read_long(Unknown Source)
    at com.sun.corba.se.impl.encoding.WrapperInputStream.read_long(Unknown Source)
    at com.sun.corba.se.impl.corba.TypeCodeImpl.read_value_kind(Unknown Source)
    at com.sun.corba.se.impl.corba.TypeCodeImpl.read_value(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream_1_0.read_any(Unknown Source)
    at com.sun.corba.se.impl.encoding.CDRInputStream.read_any(Unknown Source)
    at tests.testPOA._invoke(testPOA.java:36)
    at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleInput(Unknown Source)
    at com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(Unknown Source)
    at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.dispatch(Unknown Source)
    at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.doWork(Unknown Source)
    at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.performWork(Unknown Source)
    at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(Unknown Source)

----------END server-side stack trace----------  vmcid: SUN  minor code: 207  completed: No
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase.getSystemException(Unknown Source)
    at com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage_1_2.getSystemException(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.getSystemExceptionReply(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(Unknown Source)
    at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(Unknown Source)
    at com.sun.corba.se.impl.corba.RequestImpl.doInvocation(Unknown Source)
    at com.sun.corba.se.impl.corba.RequestImpl.invoke(Unknown Source)
    at server.TestClient.main(TestClient.java:75)

May I ask for a little help?
Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴情 2024-11-07 05:31:39

可能是参数类型的问题,与封送有关。必须使用 CORBA::string_alloc (或 java 等效项)分配字符串

Could be an issue with the type of parameters, something related with marshaling. Strings must be allocated using CORBA::string_alloc (or java equivalent)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文