2011-04-10 28 views
1

我有一個非常簡單的IDL文件:CORBA + JAVA +動態的客戶端 - 調用()Request對象的方法失敗

module tests{ 

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

使用idlj後,我寫了整個應用程序(分爲服務器/公務員/客戶端),它工作正常。我現在唯一的問題是,當我嘗試重寫客戶端,因此它可能使用動態調用時,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() beeing的犯罪嫌疑人:

(在錯誤日誌的最後一行是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) 

我可以要求一點幫助嗎? 謝謝。

+2

Corba!哇。所以你是唯一。 – MeBigFatGuy 2011-04-11 02:26:37

+0

@MeBigFatGuy - 請告訴我的教授:) – zeroDivisible 2011-04-11 03:06:48

回答

1

可能是與參數類型有關的問題,與編組有關。字符串必須使用CORBA :: string_alloc(或java等價物)分配。