Archived
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();
};
};
#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
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
0
Comments
-
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.0 -
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.0