java 为什么我会收到 NamingContextPackage.NotFound 异常?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17290708/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why do I get a NamingContextPackage.NotFound exception?
提问by reiley
I'm new in CORBA. When I run the below code, I'm getting:
我是 CORBA 的新手。当我运行下面的代码时,我得到:
Exception in thread "main" org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
线程“main” org.omg.CosNaming.NamingContextPackage.NotFound 中的异常:IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
in line:
排队:
ncRef.rebind(factoryName, rootpoa.servant_to_reference(sessionFactoryServant));
Code:
代码:
final String initHost = System.getProperty("org.omg.CORBA.ORBInitialHost",
java.net.InetAddress.getLocalHost().getHostAddress());
if (StringUtils.isNotBlank(initHost) == true)
{
properties.put("org.omg.CORBA.ORBInitialHost", initHost);
}
//final String initPort = System.getProperty("org.omg.CORBA.ORBInitialPort");
final String initPort = "1051";
if (StringUtils.isNotBlank(initPort) == true)
{
properties.put("org.omg.CORBA.ORBInitialPort", initPort);
}
// Start the ORB.
m_orb = ORB.init(m_arguments, properties);
POA rootpoa = POAHelper.narrow(m_orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
final RSSessionFactoryServant sessionFactoryServant = new RSSessionFactoryServant(rootpoa);
rootpoa.activate_object(sessionFactoryServant);
org.omg.CORBA.Object objRef = m_orb
.resolve_initial_references("NameService");
System.out.println("Name server is " + objRef + ".");
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
System.out.println("Naming context is " + ncRef + ".");
final NameComponent[] factoryName = getSessionFactory(); // Contains name components.. nothinf seems wrong here
System.out.println("Session Factory is [" + ArrayUtils.toString(factoryName) + "].");
ncRef.rebind(factoryName, rootpoa.servant_to_reference(sessionFactoryServant));
System.out.println("Server ready and waiting ...");
m_orb.run();
采纳答案by tuergeist
The object you are searching for is not known to the Naming Service. Therefor you're getting NotFound exceptions. You may want to use bind
in the first step.
命名服务不知道您正在搜索的对象。因此,您会收到 NotFound 异常。您可能希望bind
在第一步中使用。