I need help to make a test running ?

"Decoster Jean Louis" <[email protected]> Tue, 13 Dec 2005 08:55:44 +0100
Newsgroups gmane.comp.corba.orbacus
Message-ID <[email protected]>
 <<vdb_placetable.cpp.txt>>  <<eLockDb.cpp>>  <<eLockDb.cpp.txt>>  
<<elockidl.idl>>  <<elockidl.idl.txt>>  <<obj_Place.cpp>>  
<<obj_Place.cpp.txt>>  <<Start.java>>  <<Start.java.txt>>  
<<vdb_placetable.cpp>> Hello,

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

_______________________________________________
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
vdb_placetable.cpp.txt (text/plain, 403 B)
#include "stdafx.h"
#include "obj_Place.h"
#include "vdb_placetable.h"

		vdb_placetable::vdb_placetable() : placetableCorba() {}
		vdb_placetable::~vdb_placetable() {}
//
// This method returns an obj_Place object
//
::eLockidl::placeCorba_ptr	vdb_placetable::getNew() {
		//return	(::eLockidl::placeCorba_ptr) new obj_Place(this);
		return	(::eLockidl::placeCorba_ptr) new obj_Place();
		}
eLockDb.cpp (application/octet-stream, 1.8 KB) - not displayed
eLockDb.cpp.txt (text/plain, 1.8 KB)
#include <iostream>
#include "Stdafx.h"
#include "eLockDb.h"

#define P_eLockDb		//Printf funktionen ausführen erlaubt !!!!!

int startCorba(CORBA::ORB_ptr);

int main( int argc,char* argv[] ) {

	int status = EXIT_SUCCESS;
	CORBA::ORB_var orb;
	try	{
		// Interpretation of arguments starting with -ORB & -OA passed through argc & argv.
		orb = CORBA::ORB_init(argc, argv);
		status = startCorba(orb);
	}
	catch(const CORBA::Exception&) {
		status = EXIT_FAILURE;
	}
	if(!CORBA::is_nil(orb)) {
		try {
			orb->destroy();
		}
		catch(const CORBA::Exception&) {
			status = EXIT_FAILURE;
		}
	}
	return status;
}

	int startCorba(CORBA::ORB_ptr orb) {
	// Object Adapter Initialization
	CORBA::Object_var poaObj = orb->resolve_initial_references("RootPOA");
	//Get a reference to the Root POA
	PortableServer::POA_var rootPoa = PortableServer::POA::_narrow(poaObj);
	// POA Manager instanzieren
	PortableServer::POAManager_var manager = rootPoa->the_POAManager();

	// Servants creation
	obj_Place* serv_Place = new obj_Place();
	vdb_placetable* serv_vdbplacetable = new vdb_placetable();
	//
	CORBA::String_var s;
	FILE* fileref;
	
	// Table_Servant activation
	//eLockidl::placeCorba_var aaa = serv_Place->_this();
	//s = orb->object_to_string(aaa);
	//fileref = fopen("C:/place.ref","w");
	//fprintf(fileref,"%s",s);
	//fclose(fileref);

	// Placetable_Servant activation
	eLockidl::placetableCorba_var bbb = serv_vdbplacetable->_this();
	s = orb->object_to_string(bbb);
	fileref = fopen("C:/placetable.ref","w");
	fprintf(fileref,"%s",s);
	fclose(fileref);

	// Activate POA Manager
	manager->activate();
	printf("startCorba(CORBA::ORB_ptr orb) Next instruction starts Corba: orb->run(); \n");
	orb->run();
	return EXIT_SUCCESS;
}
elockidl.idl (application/octet-stream, 296 B) - not displayed
elockidl.idl.txt (text/plain, 296 B)
// 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();
	};
};
obj_Place.cpp (application/octet-stream, 433 B) - not displayed
obj_Place.cpp.txt (text/plain, 433 B)
// obj_Place.cpp: Implementierung der Klasse obj_Place.
//
//////////////////////////////////////////////////////////////////////

#include "obj_Place.h"

obj_Place::obj_Place() : placeCorba() {
		description = NULL;
		}
		obj_Place::~obj_Place()	{}
//
char*	obj_Place::getDescription() {
			return description;
		}
//
void	obj_Place::setDescription(const char* inDescription) {}

void	obj_Place::save() {}
Start.java (application/octet-stream, 2.5 KB) - not displayed
Start.java.txt (text/plain, 2.5 KB)
package eLockPlace;

import java.io.BufferedReader;
import java.io.FileReader;

import eLockidl.*;

import org.omg.CORBA.*;
import com.ooc.*;

public class Start {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println("---------- Start ----------");

        java.util.Properties props = System.getProperties();
        props.put("org.omg.CORBA.ORBClass",
        		  "com.ooc.CORBA.ORB");
        props.put("org.omg.CORBA.ORBSingletonClass",
                  "com.ooc.CORBA.ORBSingleton");
        int status = 0;
        org.omg.CORBA.ORB orb = null;

        try
        {
            orb = org.omg.CORBA.ORB.init(args, props);
            status = run(orb);
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
            status = 1;
        }

        if(orb != null)
        {
            try
            {
                orb.destroy();
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
                status = 1;
            }
        }

        System.exit(status);
    }

	static int run(org.omg.CORBA.ORB orb) {
		org.omg.CORBA.Object objPlace = null;
		org.omg.CORBA.Object objPlaceTable = null;
		try {
			String refFile;
			String refData;
			BufferedReader inBuf;
			/***************************************************
			refFile = "C:/place.ref";
			inBuf = new BufferedReader(new FileReader(refFile));
			refData = inBuf.readLine();
			objPlace = orb.string_to_object(refData);
			****************************************************/
			refFile = "C:/placetable.ref";
			inBuf = new BufferedReader(new FileReader(refFile));
			refData = inBuf.readLine();
			objPlaceTable = orb.string_to_object(refData);
			
			
			
			
		}
		catch(java.io.IOException ex) {
			ex.printStackTrace();
			return 1;
		}
		//
		placetableCorba newPlace = placetableCorbaHelper.narrow(objPlaceTable);
		System.out.println("---------- newPlace ----------");
		placeCorba myPlace; 
		//= placeCorbaHelper.narrow(objPlace);;
		System.out.println("---------- placeCorbaHelper.narrow(objPlace); ----------");
		myPlace = newPlace.getNew();
		//System.out.println("---------- newPlace.getNew(); ----------");
		/***************************************************
		myPlace.setDescription("bla bla");
		myPlace.save();
		***************************************************/
		System.out.println("---------- Ende ----------");
		return 0;
	}
}
vdb_placetable.cpp (application/octet-stream, 403 B) - not displayed