Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > omniORB C++ server, Java client problems with running aplication

Reply
Thread Tools

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

 
 
mazix8 mazix8 is offline
Junior Member
Join Date: May 2012
Posts: 1
 
      05-01-2012
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/dBAh...niORB4cfg.html
 

Last edited by mazix8; 05-01-2012 at 12:07 PM..
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to run a java aplication as service or scheduled task Lucho Java 5 01-19-2008 09:57 AM
(omniorb) Corba using with python Birgit Rahm Python 1 11-04-2004 01:15 PM
omniorb, python and callbacks Melissa Wallis Python 1 04-28-2004 02:47 PM
omniORB 4.0.3 and omniORBpy 2.3 available Duncan Grisby Python 4 12-01-2003 10:22 AM
omniORB 4.0.2 and omniORBpy 2.2 released Duncan Grisby Python 3 08-18-2003 09:26 AM



Advertisments