Home Help Center

Operator Error - NullHandleException

eric.hilleric.hill Member Eric HillOrganization: Pioneer Balloon Co.Project: Internal Research
Ok, I'm just getting started with Ice and I can't get my first attempt to work. Obviously, the hello demo works fine, so I must be missing something in my code.

I started with a simple ice definition:

#ifndef BOB_ICE
#define BOB_ICE

module BOB {
interface Shirt {
nonmutating void ping();
};
};

#endif

I then did a slice2cpp --impl bob.ice and got 4 files (bob and bobi, cpp and h) as expected. I then created a new solution and made a new source file with the following code:

#include <iostream>
#include <Ice/Ice.h>
#include <bobI.h>

using namespace std;
using namespace BOB;

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

int BOBServer::run(int argc, char* argv[]) {
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("BOB"); // <- Error happens here
Ice::Identity identity = communicator()->stringToIdentity("BOB");
adapter->add(new IndicesI, identity);
communicator()->waitForShutdown();
return 0;
}

int main(int argc, char* argv[]) {
BOBServer server;
return server.run(argc, argv);
}

I'm getting the NullHandleException on the line indicated above. What am I not doing correctly? The demo works and it uses an identical line as far as I can tell...

Thanks in advance.

Eric

Comments

  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    Welcome to our forums!

    Please see this post regarding out support policy here in these newsgroups.
  • eric.hilleric.hill Member Eric HillOrganization: Pioneer Balloon Co.Project: Internal Research
    My Apologies

    I changed my signature after receiving the welcome email and posting my initial question, assuming my signature was appended to all posted messages. Sorry. :(
  • eric.hilleric.hill Member Eric HillOrganization: Pioneer Balloon Co.Project: Internal Research
    Found The Problem

    Trivial little bug:

    int main(int argc, char* argv[]) {
    BOBServer server;
    return server.run(argc, argv);
    }

    should be changed to:

    int main(int argc, char* argv[]) {
    BOBServer server;
    return server.main(argc, argv);
    }

    If run is called instead of main, the communicator never gets set up. :D
Sign In or Register to comment.