为什么我会得到NamingContextPackage.NotFound异常?

时间:2013-06-25 06:38:07

标签: java corba

我是CORBA的新手。当我运行以下代码时,我得到了:

  

线程“main”中的异常   org.omg.CosNaming.NamingContextPackage.NotFound:   IDL:omg.org/CosNaming/NamingContext/NotFound:1.0

排队:

ncRef.rebind(factoryName,  rootpoa.servant_to_reference(sessionFactoryServant));

代码:

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();

1 个答案:

答案 0 :(得分:1)

命名服务不知道您要搜索的对象。因此,你得到了NotFound异常。您可能希望在第一步中使用bind

Oracle Doc for NamingContextOperations