Problem by calling add_binding

"Decoster Jean Louis" <[email protected]> Wed, 21 Dec 2005 09:21:40 +0100
Newsgroups gmane.comp.corba.orbacus
Message-ID <[email protected]>
Hello Dave,

First many thanks for your support. I have read Orbacus documentation about factory objects using C++ and learned quite a lot. Of course I will try to take care of your suggestions in the future.
At this moment my system goes wrong when I try to bind an ObjectId with an object to enable clients to use Corbaloc facility? I can use the object to write a reference file.

	// Try to write a reference file
	CORBA::String_var s;
	FILE* fileref;
	s = orb->object_to_string(s_placetable);
	fileref = fopen("C:/placetable.ref","w");
	fprintf(fileref,"%s",s);
	fclose(fileref);
	// Try to generate a n object-key to be used by clients
	PortableServer::ObjectId_var objId = PortableServer::string_to_ObjectId("myObjectId");
	bootManager->add_binding(objId,s_placetable);

Nicht abgefangene Ausnahme in eLOckDb_Cons.exe (MSVCRTD.DLL): 0xC0000005: Access Violation.
Nicht abgefangene Ausnahme in eLOckDb_Cons.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

I thought that my code could be correct; but it's not. Using the present information's can you tell me what I have to check to get my system running or can you tell me what you need more.

Merci à l'équipe de support d'Orbacus

Regards,
Jean-Louis




-----Ursprüngliche Nachricht-----
Von: David Weir [mailto:[email protected]] 
Gesendet: Dienstag, 13. Dezember 2005 21:46
An: Decoster Jean Louis
Cc: [email protected]
Betreff: Re: [OB-Users] I need help to make a test running ?

Hello Jean-Louis,

On Tue, Dec 13, 2005 at 08:55:44AM +0100, Decoster Jean Louis wrote:
> 
> Can somebody help me to make my test running ?
> This small test consists of an IDL with two interfaces:
> // IDL
> module eLockidl {
> 	// Place definition
> 	interface placeCorba {
> 		typedef string  description;
> 		string	getDescription();
> 		void	setDescription(in string inDescription);
> 		void	save();
> 	};
> 	// PlaceTable definition
> 	interface placetableCorba {
> 		placeCorba	getNew();
> 	};
> };
> 
> The getNew() method raises an unknown exception in the server (memory
> violation)?. I don't understand what is going wrong?.
> As attachments are all the files also in .txt format. 
> Server is in C++
> Client is in java.
> 
> I HOPE THAT I WILL RECEIVE SOME HELP SOON. THANKS FOR YOUR ANSWER.
> REGARDS,
> Jean-Louis

When submitting a test case or demo for review, I suggest that you pare
it down to the bare minimum. This will make it easier for others to
review your application and offer you some advice or help where
applicable.

First off, I should point out that following standard naming conventions
for IDL definitions would also make your work clearer for others to
review. The main point is that "interface" and "module" definitions are
typically capitalized. If you take a look at the CORBA specification and
its IDL definitions you will get a better indication of what I am
talking about.

Something else that you should be aware of is the idea of an attribute
in IDL. For example, had you simply defined an "attribute string
description" in your "placeCorba" ("PlaceCorba") interface, you would
have gotten an accessor and mutator function for free in your generated
classes. This is not always the best way to go, but it can simplify IDL
definitions to some degree if the explicit methods are not required in
the IDL definition.

As for your main issue, I believe that Darren Middleman suggested the
problem in a previous e-mail. Basically, your "getNew()" method needs to
do more than simply instantiate a C++ object on the server side. It
actually has to be responsible for instantiating a servant on the server 
side POA and returning a proper object reference for that servant.

It seems that you are trying to implement a factory type interface with
your "placeTableCorba" interface, which is quite common. But remember,
the idea of returning a CORBA object in that factory interface is to
allow the client to then invoke remote operations on that new object. In
order to do this, however, that new object must exist on a POA on the
server side, otherwise the ORB will not be able to forward requests to
it.

So, the implementation of your "getNew" method should actually know
what POA to activate your "placeCorba" servant on, then proceed to do
that activation. From the code you provided, I do not see this being
done anywhere.

Please take a closer look at the "hello" demo shipped with Orbacus for
C++. In particular look at the inheritance structure of the servant
(Hello_impl.h/.cpp), and what needs to occur in the server (Server.cpp)
to create this implementation object on the POA.

A reference that you may want to consider is "Advanced CORBA Programming
with C++", by Michi Henning and Steve Vinoski.

Cheers,
Dave

-- 
David Weir                          
Team Orbacus - Your CORBA Source
E-Mail: [email protected]
WWW: http://www.orbacus.com

_______________________________________________
OB-Users Mailing List - [email protected]
http://mail.ooc.nf.ca/mailman/listinfo/ob-users
Visit our support FAQ before you send a message.
http://www.orbacus.com/faq/support.html