Search code examples
c++dockerdocker-composecorba

CORBA exception raised: NotFound


Hello I'm trying to implement simple client/server CORBA app with docker. Here is Print.idl code :

module Test
{
  interface Printer
  {
    void print();
  };
};

Here is the client code:

#include <iostream>

#include "PrintC.h"

int main(int argc, char** argv) {
    try {
        CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
        CORBA::Object_var po = orb->string_to_object("corbaname::nameservice/NameService#test/Printer");
        Test::Printer_var p = Test::Printer::_narrow(po.in());
        p->print();
        orb->destroy();
    } catch (CORBA::Exception const& e) {
        std::cerr << "CORBA exception raised: " << e._name() << ": " << e._info().c_str() << '\n';
    }
    return 0;
}

Here is the server code:

#include <iostream>

#include <orbsvcs/CosNamingC.h>

#include "PrintS.h"

class Implement_Printer : public POA_Test::Printer {
public:
    void print() {
        std:: cout << "Hello World\n";
    }
};

int main(int argc, char** argv) {
    try {
        CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
        CORBA::Object_var object = orb->resolve_initial_references("RootPOA");
        PortableServer::POA_var poa = PortableServer::POA::_narrow(object.in());
        PortableServer::POAManager_var poa_manager = poa->the_POAManager();
        poa_manager->activate();

        Implement_Printer p;    
        Test::Printer_var printer_object = p._this();   
        object = orb->string_to_object("corbaloc::nameservice/NameService");
        CosNaming::NamingContextExt_var naming_context =
        CosNaming::NamingContextExt::_narrow(object.in());
        CosNaming::Name_var name;
        name = naming_context->to_name("test/Printer");
        naming_context->rebind(name.in(), printer_object.in());

        orb->run();

        poa->destroy(1, 1);
        orb->destroy();
    } catch (CORBA::Exception const& e) {
        std::cerr << "CORBA exception raised: " << e;
    }
    return 0;
}

And here is the docker-compose.yml :

version: '3.2'
services:
  serveur:
    image: serveur
    networks:
      - corba
    depends_on:
    - nameservice
  client:
    image: client
    networks:
      - corba
    depends_on:
    - nameservice
    - serveur
  nameservice:
    image: omninames
    networks:
      - corba
networks:
  corba:
    driver: bridge

Here is the log of docker-compose up :

nameservice_1  | omniNames: (0) 2020-06-10 15:47:16.221353: Data file: '/var/lib/omniorb/omninames-13afbf6c0191.dat'.
nameservice_1  | omniNames: (0) 2020-06-10 15:47:16.221588: Starting omniNames for the first time.
nameservice_1  | omniNames: (0) 2020-06-10 15:47:16.222368: Wrote initial data file '/var/lib/omniorb/omninames-13afbf6c0191.dat'.
nameservice_1  | omniNames: (0) 2020-06-10 15:47:16.222446: Read data file '/var/lib/omniorb/omninames-13afbf6c0191.dat' successfully.
nameservice_1  | omniNames: (0) 2020-06-10 15:47:16.222496: Root context is IOR:010000002b00000049444c3a6f6d672e6f72672f436f734e616d696e672f4e616d696e67436f6e746578744578743a312e300000010000000000000070000000010102000e0000003139322e3136382e3230382e3200f90a0b0000004e616d6553657276696365000300000000000000080000000100000000545441010000001c0000000100000001000100010000000100010509010100010000000901010003545441080000008400e15e01000001
nameservice_1  | omniNames: (0) 2020-06-10 15:47:16.222546: Checkpointing Phase 1: Prepare.
nameservice_1  | omniNames: (0) 2020-06-10 15:47:16.222634: Checkpointing Phase 2: Commit.
nameservice_1  | omniNames: (0) 2020-06-10 15:47:16.222783: Checkpointing completed.
serveur_1      | CORBA exception raised: NotFound (IDL:omg.org/CosNaming/NamingContext/NotFound:1.0)
corba_docker_serveur_1 exited with code 139
corba_docker_client_1 exited with code 139

According to the doc the error is due to "The Name or one of its components, could not be found. If this exception is raised because the binding already exists or the binding is of the wrong type, the rest_of_name member of the exception has a length of 1."

This code is inspired of https://github.com/cromo/multicontainer-corba/


Solution

  • Thanks to Wireshark, I have obtained more info about the error. wireshark

    Thus it seems to replace :

    name = naming_context->to_name("test/Printer")
    

    by

    name = naming_context->to_name("Printer")
    

    works. (Same thing for the client code)