omniORB C++ server, Java client problems with running aplication

Discussion in 'Software' started by mazix8, May 1, 2012.

  1. mazix8

    mazix8

    Joined:
    May 1, 2012
    Messages:
    1
    Hi guys,

    i have problem with running my application. I have a server:

    Code:
    #include "Hello_impl.h"
    #include <iostream>
    #include <omniORB4/CORBA.h>
    #include <omniORB4/Naming.hh>
    
    using namespace std;
    
    int main(int argc, char ** argv)
    {
    try {
    // init ORB
    CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv);
    
    // init POA
    CORBA::Object_var poa_obj = orb->resolve_initial_references("RootPOA");
    PortableServer::POA_var poa = PortableServer::POA::_narrow(poa_obj);
    PortableServer::POAManager_var manager = poa->the_POAManager();
    
    // create service
    Hello_impl * service = new Hello_impl;
    
    // register within the naming service
    try {
    CORBA::Object_var ns_obj = orb->resolve_initial_references("NameService");
    if (!CORBA::is_nil(ns_obj)) {
    CosNaming::NamingContext_ptr nc = CosNaming::NamingContext::_narrow(ns_obj);
    CosNaming::Name name;
    name.length(1);
    name[0].id = CORBA::string_dup("TestServer");
    name[0].kind = CORBA::string_dup("");
    nc->rebind(name, service->_this());
    cout << "Server is running ..." << endl;
    }
    } catch (CosNaming::NamingContext::NotFound &) {
    cerr << "not found" << endl;
    } catch (CosNaming::NamingContext::InvalidName &) {
    cerr << "invalid name" << endl;
    } catch (CosNaming::NamingContext::CannotProceed &) {
    cerr << "cannot proceed" << endl;
    }
    
    // run
    manager->activate();
    orb->run();
    
    // clean up
    delete service;
    
    // quit
    orb->destroy();
    } catch (CORBA::UNKNOWN) {
    cerr << "unknown exception" << endl;
    } catch (CORBA::SystemException &) {
    cerr << "system exception" << endl;
    }
    }
    and a Client:

    Code:
    import java.util.*;
    
    public class client {
    public static void main(String [] args) {
    org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);
    if (orb == null) System.exit(-1);
    try {
    // obtain service from naming server
    org.omg.CORBA.Object ns_obj = orb.resolve_initial_references("NameService");
    org.omg.CosNaming.NamingContext nc
    = org.omg.CosNaming.NamingContextHelper.narrow(ns_obj);
    org.omg.CosNaming.NameComponent [] path
    = { new org.omg.CosNaming.NameComponent("TestServer", "") };
    org.omg.CORBA.Object obj = nc.resolve(path);
    Hello hello = HelloHelper.narrow(obj);
    
    // use service
    String server = hello.say_hello("Hello, omniORB C++ server, it's Java client");
    System.out.println("Answer from server: " + server);
    
    // destroy
    orb.destroy();
    } catch (org.omg.CORBA.ORBPackage.InvalidName exception) {
    exception.printStackTrace(System.out);
    } catch (org.omg.CosNaming.NamingContextPackage.NotFound exception) {
    exception.printStackTrace(System.out);
    } catch (org.omg.CosNaming.NamingContextPackage.CannotProceed exception) {
    exception.printStackTrace(System.out);
    } catch (org.omg.CosNaming.NamingContextPackage.InvalidName exception) {
    exception.printStackTrace(System.out);
    } catch (org.omg.CORBA.COMM_FAILURE exception) {
    exception.printStackTrace(System.out);
    } catch (Exception exception) {
    exception.printStackTrace(System.out);
    }
    }
    }
    I start omniNames like this: omniNames -start 6666 -logdir /home/mazix/Desktop/example/logs -errlog /home/mazix/Desktop/example/logs/omniNamesError.txt

    then, i start my server, like this: ./server -ORBInitRef NameService=IOR: .... (and here is my IOR num)


    and I start client (on the same computer) : like this: java client -ORBInitRef NameService=corbaloc::localhost:6666/NameService


    And its working but I would like to start my server like this: ./server -ORBInitialHost localHist -ORBInitialPort 6666 and clinet: java client -ORBInitialHost localHist -ORBInitialPort 6666 but its not working when I start it like that :(

    Any help? :(

    Here's my omniORB configuration file: http://www.2shared.com/document/dBAhFGLh/omniORB4cfg.html
    Last edited: May 1, 2012
    mazix8, May 1, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SUPERJSM
    Replies:
    6
    Views:
    2,287
  2. danko

    defender24 spyware aplication removal

    danko, May 31, 2006, in forum: Computer Support
    Replies:
    1
    Views:
    354
    Ron Martell
    May 31, 2006
  3. etakay
    Replies:
    0
    Views:
    464
    etakay
    Mar 17, 2007
  4. =?Utf-8?B?RG9u?=

    Running Terminal Server 2003 farm on Virtual Server 2005R2

    =?Utf-8?B?RG9u?=, Aug 3, 2007, in forum: Windows 64bit
    Replies:
    2
    Views:
    881
    =?Utf-8?B?VG9ueSBNUw==?=
    Sep 11, 2007
  5. jackhen
    Replies:
    1
    Views:
    531
Loading...

Share This Page