Board index » cppbuilder » ACE+TAO troubles

ACE+TAO troubles


2007-09-05 03:43:22 AM
cppbuilder89
I'm having a lot of difficulties getting ACE+TAO to work in BCB 6, despite
its supposed native BCB support.
In a nutshell, I am trying to use a third-party SDK (Avaya Contact API).
The SDK includes ACE+TAO_1.4.6.zip in it. I spent over a week trying to get
that version of ACE+TAO to compile into static libs that BCB could use. The
makefiles that are provided are not adequate. I got all kinds of unresolved
externals, references to missing headers, etc. I followed the instructions
at www.tenermerx.com/programming/corba/tao_bcb/index.html to the
letter, but still had problems.
So I figured that maybe the distribution was bad, so I downloaded the latest
version (ACE-5.5+TAO-1.5.zip) from
www.cs.wustl.edu/~schmidt/TAO.html, but then I had a different set of
problems in compiling.
Long story short, 2 weeks into it, I finally got everything to built and
link properly. But now I'm getting a runtime error in my client app.
Specifically, resolve_initial_references("NameService") is crashing with an
AV every time, regardless of whether Naming_Service.exe is running. Oddly
enough, the nslist.exe utility that I compiled from TAO is able to make the
same API call and it succeeds without crashing :-(
My client code is below. It is adapted from a snippet that I copy/pasted
from the SDK's documentation. I have ACE_AS_STATIC_LIBS=1,
TAO_AS_STATIC_LIBS=1, ACE_HAS_WINSOCK2=1, and ACE_HAS_VCL=1 defined in my
project conditionals.
//#include <vcl.h>
#include <tao/corba.h>
#pragma hdrstop
#include "Main.h"
#include <fstream.h>
#include <time.h>
#include "ace/Get_Opt.h"
#include "CosNamingC.h"
#include "EventClientS.h"
#include "EventServerC.h"
#include "StringConvert.h"
#include "ace/SString.h"
using namespace EventServer;
using namespace ESType;
using namespace Common;
#include "EventClient.h"
#include "EventClient_i.h"
// forward declarations:
// TODO: finish implementing this...
CORBA::Object_ptr import_object (CORBA::ORB_ptr, const char *) { return 0; }
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "mswsock.lib")
//--------------------------------------------------------------------------
-
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
// Create the client global object:
client_global_t client_global_obj;
client_global_t *g = &client_global_obj;
//--------------------------------------------------------------------------
-
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
CORBA::ORB_var orb = CORBA::ORB::_nil ();
try
{
orb = CORBA::ORB_init (_argc, _argv, "TAO");
}
catch (...)
{
ShowMessage("Error: ORB_init failed");
return;
}
PortableServer::POA_var child_poa;
PortableServer::POAManager_var poa_manager;
try
{
CORBA::Object_var objV;
CosNaming::NamingContext_var rootContext;
// Initialize the ORB:
CORBA::Object_var poa_obj = orb->resolve_initial_references
("RootPOA");
// Narrow the Root POA to POA_var:
PortableServer::POA_var root_poa = PortableServer::POA::_narrow
(poa_obj);
if (CORBA::is_nil (root_poa))
{
ShowMessage("root_poa is nil");
return;
}
// Share the root POAs POA Manager:
poa_manager = root_poa->the_POAManager ();
// Create the Empty Sequence for Default POA Policies:
CORBA::PolicyList policyList;
policyList.length (0);
child_poa = root_poa->create_POA ("child", poa_manager, policyList);
objV = orb->resolve_initial_references ("NameService"); // <- AV ON
THIS LINE!!!!
rootContext = CosNaming::NamingContext::_narrow (objV);
if (CORBA::is_nil (rootContext))
{
ShowMessage("rootContext is nil");
return;
}
if (g->using_IOR_flag)
{
objV = import_object (orb, g->IOR_file);
}
else
{
// Construct a Name:
CosNaming::Name serverNameV;
serverNameV.length (5);
serverNameV[0].id = CORBA::string_dup ("PDS");
serverNameV[0].kind = CORBA::string_dup ("");
serverNameV[1].id = CORBA::string_dup ("dialers");
serverNameV[1].kind = CORBA::string_dup ("");
serverNameV[2].id = CORBA::string_dup (g->server_host);
serverNameV[2].kind = CORBA::string_dup ("");
serverNameV[3].id = CORBA::string_dup ("eventserver");
serverNameV[3].kind = CORBA::string_dup ("");
serverNameV[4].id = CORBA::string_dup ("v2_0");
serverNameV[4].kind = CORBA::string_dup ("");
// Now resolve with name server
objV = rootContext->resolve (serverNameV);
}
g->serverV = DialerEventServerIF::_narrow (objV);
if (CORBA::is_nil (g->serverV))
{
ShowMessage("Error: failed to narrow object reference");
return;
}
}
catch (const CORBA::SystemException &)
{
ShowMessage("Unexpected system exception");
return;
}
catch (...)
{
// an error occurred while trying to bind to the object.
ShowMessage("Error: Bind to object failed");
return;
}
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// connect to Avaya and do something
}
//--------------------------------------------------------------------------
-
//--------------------------------------------------------------------------
-
void ace_init(void)
{
ACE::init();
}
#pragma startup ace_init
void ace_fini(void)
{
ACE::fini();
}
#pragma exit ace_fini
Gambit
 
 

Re:ACE+TAO troubles

"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >writes:
Quote
I'm having a lot of difficulties getting ACE+TAO to work in BCB 6, despite
its supposed native BCB support.
Sorry to hear that. I can't say I have much experience with ACE+TAO
on windows (nor with Borland), since 1999 or so.
Quote
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
...
objV = orb->resolve_initial_references ("NameService"); // <- AV ON
...
}
Just a few thoughts:
Is it possible that TForm1's constructor is running before main()?
Does it work with dynamic libraries instead of static ones?
--
Chris (TeamB);
 

Re:ACE+TAO troubles

"Chris Uzdavinis (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote
Is it possible that TForm1's constructor is running before main()?
No. This is a Win32 app, not a console app, so there is a WinMain()
function instead of main(). But in any case, TForm1 is constructed inside
of WinMain().
Quote
Does it work with dynamic libraries instead of static ones?
I have no clue. It takes literally hours to compile TAO. I have had to do
that so many times over the past 2 weeks, I'm not looking forward to doing
it again. But I'll give it a try and see what happens.
Gambit
 

{smallsort}

Re:ACE+TAO troubles

"Chris Uzdavinis (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote
Does it work with dynamic libraries instead of static ones?
It doesn't make sense why nslist.exe would work, though. That was compiled
statically using the same libs. And also, the first call to
resolve_initial_references("RootPOA") works fine in my code, so I think the
function itself is ok.
Gambit
 

Re:ACE+TAO troubles

"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >writes:
Quote
"Chris Uzdavinis (TeamB)" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>Does it work with dynamic libraries instead of static ones?

It doesn't make sense why nslist.exe would work, though. That was
compiled statically using the same libs. And also, the first call
to resolve_initial_references("RootPOA") works fine in my code, so I
think the function itself is ok.
You might look at all the build options and see if anything is
different. I seem to remember running into a problem involving
different compile options for the .exe as for the libraries linked to
it.
If I recall the "empty member optimization" screwed up offsets when
data was passed between my library and executable (since only one had
it enabled.
Perhaps it is something along those lines.
--
Chris (TeamB);
 

Re:ACE+TAO troubles

"Chris Uzdavinis (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote
You might look at all the build options and see if anything is
different. I seem to remember running into a problem involving
different compile options for the .exe as for the libraries linked to
it.
I was just thinking the same thing. I just noticed that "Use dynamic RTL"
was enabled in the client app, so I just turned that off and I'm not getting
an AV anymore. But I am now getting a "CORBA::ORB::InvalidName" exception
instead on the same function call.
Gambit
 

Re:ACE+TAO troubles

"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >writes:
Quote
"Chris Uzdavinis (TeamB)" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>You might look at all the build options and see if anything is
>different. I seem to remember running into a problem involving
>different compile options for the .exe as for the libraries linked to
>it.

I was just thinking the same thing. I just noticed that "Use dynamic RTL"
was enabled in the client app, so I just turned that off and I'm not getting
an AV anymore. But I am now getting a "CORBA::ORB::InvalidName" exception
instead on the same function call.
I'm afraid that is going outside my knowledge of Corba. (We were deep
into it years ago, but now it is something I've mostly forgotton, as
our application has hidden it away behind our own layers.)
--
Chris (TeamB);
 

Re:ACE+TAO troubles

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote
But I am now getting a "CORBA::ORB::InvalidName"
exception instead on the same function call.
I figured that out. I wasn't passing the NameService's host/port to
CORBA::ORB_Init(), so it couldn't figure out where to find it.
Gambit
 

Re:ACE+TAO troubles

Remy Lebeau (TeamB) wrote:
Quote
objV = orb->resolve_initial_references ("NameService"); // <- AV ON
THIS LINE!!!!
As you have the source code, you could try stepping in and see where
exactly the AV occures.
Along what Chris suggested, the -b option could bite you badly if set
differently betwen .exe and .lib