CORBA 错误:方法中的 ORB 初始化
Posted
技术标签:
【中文标题】CORBA 错误:方法中的 ORB 初始化【英文标题】:CORBA Error : ORB initialization in a method 【发布时间】:2014-11-07 20:35:33 【问题描述】:我正在从客户端调用服务器端的方法。我有三台服务器,它们需要使用 UDP 进行通信,所以在方法中我需要再次初始化 orb 以启动线程进程。但我很确定这是因为 ORB 初始化中的问题
我在服务器端的方法:
public String getNonReturners(String adminUsername, String adminPassword,
String educationalInstitution, int numDays)
String _result = null;
String _initiatedServerResult = null;
final ArrayList<String> result = new ArrayList<String>();
try
ORB orb = ORB.init();
POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
BufferedReader brConcordia = new BufferedReader(new FileReader(
"concordia.txt"));
String concordia = brConcordia.readLine();
brConcordia.close();
BufferedReader brMcgill = new BufferedReader(new FileReader(
"mcgill.txt"));
String mcgill = brMcgill.readLine();
brMcgill.close();
BufferedReader brDawson = new BufferedReader(new FileReader(
"dawson.txt"));
String dawson = brDawson.readLine();
brDawson.close();
org.omg.CORBA.Object concordiaObject = orb.string_to_object(concordia);
org.omg.CORBA.Object mcgillObject = orb.string_to_object(mcgill);
org.omg.CORBA.Object dawsonObject = orb.string_to_object(dawson);
final DRMSInterface _concordiaServer = DRMSInterfaceHelper
.narrow(concordiaObject);
final DRMSInterface _mcgillServer = DRMSInterfaceHelper
.narrow(mcgillObject);
final DRMSInterface _dawsonServer = DRMSInterfaceHelper
.narrow(dawsonObject);
if (educationalInstitution.toLowerCase().equals("concordia"))
final Thread t1 = new Thread()
@Override
public void run()
result.add(_mcgillServer
.responseData(_mcgillPortNumber));
;
t1.setDaemon(true);
t1.start();
final Thread t2 = new Thread()
@Override
public void run()
result.add(_dawsonServer
.responseData(_dawsonPortNumber));
;
t2.setDaemon(true);
t2.start();
System.out.println("Attemping to connect to " + IPAddress
+ ") via UDP port" + _mcgillPortNumber);
result.add("Attemping to connect to " + IPAddress
+ ") via UDP port" + _mcgillPortNumber);
result.add("/n");
System.out.println("Attemping to connect to " + IPAddress
+ ") via UDP port" + _dawsonPortNumber);
result.add("Attemping to connect to " + IPAddress
+ ") via UDP port" + _dawsonPortNumber);
result.add("/n");
final String _concordiaRequestMessage = educationalInstitution
+ numDays;
System.out.println("Sending data "
+ _concordiaRequestMessage.length()
+ " bytes to server.");
result.add("Sending data " + _concordiaRequestMessage.length()
+ " bytes to server.");
result.add(_concordiaServer.requestData(_mcgillPortNumber,
_concordiaRequestMessage));
result.add(_concordiaServer.requestData(_dawsonPortNumber,
_concordiaRequestMessage));
_initiatedServerResult = _concordiaServer.getNonReturnersData(
educationalInstitution, numDays);
if (_initiatedServerResult != null)
result.add(_initiatedServerResult);
else
result.add("No Defaulters in Concordia");
else if (educationalInstitution.toLowerCase().equals("mcgill"))
final Thread t1 = new Thread()
@Override
public void run()
result.add(_concordiaServer
.responseData(_concordiaPortNumber));
;
t1.setDaemon(true);
t1.start();
final Thread t2 = new Thread()
@Override
public void run()
result.add(_dawsonServer
.responseData(_dawsonPortNumber));
;
t2.setDaemon(true);
t2.start();
System.out.println("Attemping to connect to " + IPAddress
+ ") via UDP port" + _concordiaPortNumber);
result.add("Attemping to connect to " + IPAddress
+ ") via UDP port" + _concordiaPortNumber);
System.out.println("Attemping to connect to " + IPAddress
+ ") via UDP port" + _dawsonPortNumber);
result.add("Attemping to connect to " + IPAddress
+ ") via UDP port" + _dawsonPortNumber);
final String _mcgillRequestMessage = educationalInstitution
+ numDays;
System.out.println("Sending data "
+ _mcgillRequestMessage.length() + " bytes to server.");
result.add("Sending data " + _mcgillRequestMessage.length()
+ " bytes to server.");
result.add(_mcgillServer.requestData(_concordiaPortNumber,
_mcgillRequestMessage));
result.add(_mcgillServer.requestData(_dawsonPortNumber,
_mcgillRequestMessage));
_initiatedServerResult = _mcgillServer.getNonReturnersData(
educationalInstitution, numDays);
if (_initiatedServerResult != null)
result.add(_initiatedServerResult);
else
result.add("No Defaulters in Mcgill");
else if (educationalInstitution.toLowerCase().equals("dawson"))
final Thread t1 = new Thread()
@Override
public void run()
result.add(_concordiaServer
.responseData(_concordiaPortNumber));
;
t1.setDaemon(true);
t1.start();
final Thread t2 = new Thread()
@Override
public void run()
result.add(_mcgillServer
.responseData(_mcgillPortNumber));
;
t2.setDaemon(true);
t2.start();
System.out.println("Attemping to connect to " + IPAddress
+ ") via UDP port" + _concordiaPortNumber);
result.add("Attemping to connect to " + IPAddress
+ ") via UDP port" + _concordiaPortNumber);
System.out.println("Attemping to connect to " + IPAddress
+ ") via UDP port" + _mcgillPortNumber);
result.add("Attemping to connect to " + IPAddress
+ ") via UDP port" + _mcgillPortNumber);
final String _dawsonRequestMessage = educationalInstitution
+ numDays;
System.out.println("Sending data "
+ _dawsonRequestMessage.length() + " bytes to server.");
result.add("Sending data " + _dawsonRequestMessage.length()
+ " bytes to server.");
result.add(_dawsonServer.requestData(_concordiaPortNumber,
_dawsonRequestMessage));
result.add(_dawsonServer.requestData(_mcgillPortNumber,
_dawsonRequestMessage));
result.add(_concordiaServer.getNonReturnersData(
educationalInstitution, numDays));
_initiatedServerResult = _dawsonServer.getNonReturnersData(
educationalInstitution, numDays);
if (_initiatedServerResult != null)
result.add(_initiatedServerResult);
else
result.add("No Defaulters in Dawson");
catch (IOException e)
e.printStackTrace();
catch (InvalidName e)
// TODO Auto-generated catch block
e.printStackTrace();
return _result = result.toString();
我尝试了这个问题的最后一个答案,但没有帮助。 calling args from out side the main method
错误:
org.omg.CORBA.NO_IMPLEMENT: ----------BEGIN server-side stack trace----------
org.omg.CORBA.NO_IMPLEMENT: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.se.impl.logging.ORBUtilSystemException.genericNoImpl(Unknown Source)
at com.sun.corba.se.impl.logging.ORBUtilSystemException.genericNoImpl(Unknown Source)
at com.sun.corba.se.impl.orb.ORBSingleton.resolve_initial_references(Unknown Source)
at DistributedReservationManagementSystem.DRMSInterfaceImpl.getNonReturners(DRMSInterfaceImpl.java:448)
at DistributedReservationManagementSystem.DRMSInterfacePOA._invoke_getNonReturners(DRMSInterfacePOA.java:224)
at DistributedReservationManagementSystem.DRMSInterfacePOA.access$9(DRMSInterfacePOA.java:215)
at DistributedReservationManagementSystem.DRMSInterfacePOA$Operation_getNonReturners.invoke(DRMSInterfacePOA.java:385)
at DistributedReservationManagementSystem.DRMSInterfacePOA._invoke(DRMSInterfacePOA.java:73)
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: 201 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 org.omg.CORBA.portable.ObjectImpl._invoke(Unknown Source)
at DistributedReservationManagementSystem._DRMSInterfaceStub.getNonReturners(_DRMSInterfaceStub.java:502)
at DistributedReservationManagementSystem.DRMSInterfaceClient.main(DRMSInterfaceClient.java:362)
【问题讨论】:
【参考方案1】:我从属性文件中读取它这样解决它:
try
Properties prop = new Properties();
String[] orbarg = new String[2];
try
// load a properties file
prop.load(new FileInputStream("config.properties"));
// get the property value and print it out
orbarg[0] = "-ORBInitRef"; // <---- NEEDED
orbarg[1] = prop.getProperty("ORBInitRef");
catch (IOException ex)
ex.printStackTrace();
ORB orb = ORB.init(orbarg,null);
即使我们将一个空白字符串数组作为参数传递它也可以工作
【讨论】:
以上是关于CORBA 错误:方法中的 ORB 初始化的主要内容,如果未能解决你的问题,请参考以下文章
CORBA.TRANSIENT 的考虑事项:初始和转发的 IOR 不可访问 vmcid:IBM 次要代码:E07 错误
CORBA orb.resolve_initial_references("ORBPolicyManager");不工作