문제

I'm new in CORBA. When I run the below code, I'm getting:

Exception in thread "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();
도움이 되었습니까?

해결책

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.

Oracle Doc for NamingContextOperations

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top