gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 08:39:41 25 4
gpt4 key购买 nike

我有一个非常简单的 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)

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

最佳答案

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

关于java - CORBA + JAVA + 动态客户端 - Request 对象的 invoke() 方法失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5615133/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com