Results 1 to 11 of 11

Thread: Writing an ice application with java

  1. #1
    Matthieu is offline Registered User
    Name: Mat Rei
    Organization: 4sxs Consulting
    Project: communication
    Join Date
    Oct 2008
    Posts
    14

    Writing an ice application with java

    Hello !

    I try to learn how to use Ice and so I tried to compile and execute the Hello world application discribe in the Ice documentation.

    I wrote exactly the Server.cpp file, the compilation on windows was successful but when I execute it I have an "std::bad_alloc à l'emplacement mémoire 0x0012f0b8" error !

    The exact line which throws the error is :
    Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints("SimplePrinterAd apter", "default -p 1000");

    Thank you for your help !
    Matthieu

  2. #2
    bernard's Avatar
    bernard is offline ZeroC Staff
    Name: Bernard Normier
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Palm Beach Gardens, FL
    Posts
    1,294
    Hi Matthieu,

    Welcome to our forums! It's surprising that you would run out of memory with such a simple C++ program. Did you try any of the demos that comes with Ice?

    Also, check that you're linking with the proper libraries. See http://www.zeroc.com/faq/windowsLibraryMixup.html.

    Cheers,
    Bernard
    Bernard Normier
    ZeroC, Inc.

  3. #3
    Matthieu is offline Registered User
    Name: Mat Rei
    Organization: 4sxs Consulting
    Project: communication
    Join Date
    Oct 2008
    Posts
    14
    Thank you for your quick answer, I tried to compile and run the hello demo from Ice and it works !!

    I compared therefore the source files :

    - the demo use always the function communicator() instead of initialize a object "Ice::CommunicatorPtr ic = Ice::initialize(argc, argv);". What is this function ?

    - furthermore, the demo use a file called config.client or config.server. What are their utility ? Are they absolutely necessary ?

    Sorry for the langage mistakes, english is not my first langage !
    Matthieu

  4. #4
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    Hi Matthieu,

    The Ice hello application uses the Ice::Application helper class to initialize the communicator. It also provides other functionalities such as clean shutdown on interrupts, see here for more information on this class.

    Using this class or property configuration files is not required, see demo/Ice/minimal for an example that doesn't use Ice::Application or configuration files.

    Cheers,
    Benoit.

  5. #5
    Matthieu is offline Registered User
    Name: Mat Rei
    Organization: 4sxs Consulting
    Project: communication
    Join Date
    Oct 2008
    Posts
    14

    Still an out of memory...

    I have still my out of memory error...

    It is possible that this "out of memory" comes from a version problem ? I compile on visual C++ Express 2008 with the Ice Version 3.2.1. I can't change the Ice version because I am improving a existing project using this previous version. Should I install Visual Studio 2005 ?

    Thank you,
    Matthieu

    My file is :

    #include <Ice/Ice.h>
    #include "Affcarre.h"

    using namespace std;

    class Server : public Ice::Application
    {
    public:
    virtual int run(int argc, char* argv[]);
    };

    int main(int argc, char* argv[])
    {
    Server app;
    int status = app.main(argc, argv);
    return status;
    }

    int Server::run(int argc, char* argv[])
    {
    Ice::PropertiesPtr properties = communicator()->getProperties();
    Ice::ObjectAdapterPtr affcarre_adapter = communicator()->createObjectAdapter("Aaffcarre");
    Ice::Identity affcarre_id = communicator()->stringToIdentity("affcarre");
    affcarre_adapter->add(new Affcarre(properties->getProperty("Ice.ServerId")), affcarre_id);
    affcarre_adapter->activate();
    communicator()->waitForShutdown();
    return 0;
    }

  6. #6
    dwayne's Avatar
    dwayne is offline ZeroC Staff
    Name: Dwayne Boone
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Jan 2005
    Location
    St. John's, Newfoundland
    Posts
    397
    C++ Express 2008 was not a supported compiler for Ice 3.2.1, it was not supported until Ice 3.3. See here for the platform list for Ice 3.2.1. Therefore it is possible that it is a compiler issue. Still it is odd that the Ice demos work and your example does not. Are you using the same build options when building your application as the Ice demos use?
    Last edited by dwayne; 10-22-2008 at 08:47 AM.

  7. #7
    Matthieu is offline Registered User
    Name: Mat Rei
    Organization: 4sxs Consulting
    Project: communication
    Join Date
    Oct 2008
    Posts
    14
    Thank you for your answer !

    The error of out of memory disapeard ! It was a problem as Bernard said ! I used the ice.lib and iceutil.lib in debug mod. Then I tried in release mod, and it compile!

    ++
    Matthieu

  8. #8
    Matthieu is offline Registered User
    Name: Mat Rei
    Organization: 4sxs Consulting
    Project: communication
    Join Date
    Oct 2008
    Posts
    14

    New problem !!

    Hello, I am back with a new problem !

    The out_of_memory problem resolved, I have now a InitializationException at the same line.

    "Exception de première chance à 0x7c812aeb dans Serv_Ex_2_Icar.exe*: Exception Microsoft C++*: Ice::InitializationException à l'emplacement mémoire 0x0012f89c.."

    This error appears on the second line (when I want to create the ObjectAdapter) when compiling this :

    int GridServer::run(int argc, char* argv[])
    {
    Ice::PropertiesPtr properties = communicator()->getProperties();

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Aname");

    adapter->add(new Name(properties->getProperty("Ice.ServerId")), communicator()->stringToIdentity("name"));

    adapter->activate();

    adapter = communicator()->createObjectAdapter("Acarre");

    adapter->add(new Carre(properties->getProperty("Ice.ServerId")), communicator()->stringToIdentity("carre"));

    adapter->activate();

    communicator()->waitForShutdown();

    return EXIT_SUCCESS;
    }



    I tried in Release mod with the file Ice.lib and IceUtil.lib, and in Debug mod with the files Iced.lib and IceUtild.lib, there is the same error.

    I work with VS 2008 and the Ice 3.3.0 version.

    Thank you,
    Matthieu

  9. #9
    matthew's Avatar
    matthew is offline ZeroC Staff
    Name: Matthew Newhook
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Feb 2003
    Location
    NL, Canada
    Posts
    1,458
    Do you have configuration set for the object adapters (ie: Aname.Endpoints and Acarre.Endpoints)? Also, why are you creating two object adapters? That is almost never necessary. See http://www.zeroc.com/faq/multipleOA.html for details.

  10. #10
    Matthieu is offline Registered User
    Name: Mat Rei
    Organization: 4sxs Consulting
    Project: communication
    Join Date
    Oct 2008
    Posts
    14
    Thank you very much for your answer !

    I switched this line :

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Aname");

    with this line :

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints("Aname", "tcp -p 10000");


    After that I wanted to use just one adpater. So I created a object adapter then add the two objects :

    adapter->add(new Name(properties->getProperty("Ice.ServerId")), communicator()->stringToIdentity("name"));

    adapter->add(new Carre(properties->getProperty("Ice.ServerId")), communicator()->stringToIdentity("carre"));

    adapter->activate();


    It is correct ?? Because when I use my client, itjust see the first object "name". So I create two adapters with two different port numbers (tcp -p 10000 and tcp - p 10001), and it works.
    But I use a client application, which I didn't developp myself. My project is to improved this former application, so maybe the past team developp the client with several object adapter... It is really a problem to have several object adapters for one server ?


    The port number ("tcp -p 10000") have to be unique : one number for one object adapter ?

    Cheers,
    Matthieu

  11. #11
    matthew's Avatar
    matthew is offline ZeroC Staff
    Name: Matthew Newhook
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Feb 2003
    Location
    NL, Canada
    Posts
    1,458
    Quote Originally Posted by Matthieu View Post
    ....
    It is correct ?? Because when I use my client, itjust see the first object "name".
    From an Ice point of view, what you have done is correct. If your client is only seeing one object, then the client must have some expectation you are not meeting.

    So I create two adapters with two different port numbers (tcp -p 10000 and tcp - p 10001), and it works.
    But I use a client application, which I didn't developp myself. My project is to improved this former application, so maybe the past team developp the client with several object adapter... It is really a problem to have several object adapters for one server ?
    Multiple object adapters means multiple endpoints so it is not ideal.

    The port number ("tcp -p 10000") have to be unique : one number for one object adapter ?
    The ports must be unique, yes.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Is the ICE for Java based on Java NIO?
    By Jiangyubao in forum Comments
    Replies: 1
    Last Post: 03-30-2008, 06:04 PM
  2. writing a Bandwidth Shaping plugin
    By emasab in forum Help Center
    Replies: 1
    Last Post: 10-12-2007, 07:36 AM
  3. Java application on Linux Redhat
    By Vladja in forum Help Center
    Replies: 2
    Last Post: 06-08-2007, 07:32 AM
  4. Wrapping Ice.Application with Java
    By gumshoe in forum Help Center
    Replies: 2
    Last Post: 02-01-2007, 05:32 PM
  5. Documentation:Writing a ice application with Java
    By dipakyadav in forum Bug Reports
    Replies: 1
    Last Post: 02-24-2003, 01:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •