This forum has been archived. Please start a new discussion on GitHub.

Operator Error - NullHandleException

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();


I then did a slice2cpp --impl 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 {
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);
return 0;

int main(int argc, char* argv[]) {
BOBServer server;
return, 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.



  • marc
    marc Florida
    Welcome to our forums!

    Please see this post regarding out support policy here in these newsgroups.
  • 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. :(
  • Found The Problem

    Trivial little bug:

    int main(int argc, char* argv[]) {
    BOBServer server;
    return, 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