У меня есть очень простой файл IDL:
module tests{
interface test {
boolean isEquals(in any num1, in any num2);
};
};
После использования idlj
я написал все приложение (разделенное на сервер / слугу / клиент), и оно работает нормально.Моя единственная проблема сейчас заключается в том, что когда я пытаюсь переписать клиент, чтобы он мог использовать динамический вызов, метод ivoke()
объекта Requst завершился неудачей.
Код для клиента:
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)
Могу ли я попросить немного помощи?Спасибо.