我有一个非常简单的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)
我可以请求一点帮助吗? 谢谢。
答案 0 :(得分:1)
可能是参数类型的问题,与编组有关。必须使用CORBA :: string_alloc(或java等效)
分配字符串