Archived

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

addobjectwithtype problem

Hello:
I want to add a object using "addObjectWithType",but I have some problem.
Here is my code:

config:(this config is for icegridregistry)
IceGrid.InstanceName=repIceGrid
Ice.Default.Locator=repIceGrid/Locator:default -p 12000

server
Ice::ObjectPtr object = new HelloI("SimpleServer2");
//Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints("Hello", "default -h 127.0.0.1 -p 12000");
//Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello");
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints("Hello", "default");
Ice::ObjectPrx proxy = adapter->add(object, communicator()->stringToIdentity("hello2"));
IceGrid::AdminPrx admin = IceGrid::AdminPrx::checkedCast(ic->stringToProxy("repIceGrid/Admin"));
admin->addObjectWithType(proxy, proxy->ice_id());
try
{
admin->addObjectWithType(proxy,proxy->ice_id());
adapter->activate();
communicator()->waitForShutdown();
return EXIT_SUCCESS;
}
catch (const IceGrid::ObjectExistsException &)
{
admin->updateObject(proxy);
}

First I start registry using icegridregistry --Ice.Config=config
Then I start server,but I get some exception.(ps:The registry and server run in the same host)
when I use
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints("Hello", "default");
I get "Reference.cpp:1239: Ice::NoEndpointExceptin no suitable endpoint available for proxy `repIceGrid/Admin -t'"
and when I use
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello")
I get "ObjectAdapterI.cpp:778: Ice::InitializationException:initialization exception:
object adapter "Hello" requires configuration."
and when I use
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints("Hello", "default -h 127.0.0.1 -p 12000");
I get " Network.cpp:485: Ice::SocketException:socket exception: WSAEADDRINUSE"

why?What should I do if I want to add a object with "addObjectWithType".Could you give me a demo?
Thank you very much!

Comments

  • benoit
    benoit Rennes, France
    Hi,

    Which Ice version do you use? With Ice version >= 3.2.0, you can't access the admin object through a well-known proxy ("repIceGrid/Admin"), you first need to create an administrative session.

    See the manual here for more information on how to do this. Note that we only provide free support for Ice 3.2.1 on the forums, so I recommend to upgrade if you're using an older version ;).

    You should also take a look like at the IceGrid demos for information on how to setup your servers and the IceGrid registry. You'll also find many IceGrid articles here. If you didn't already check it out, you should take a look at the "Teach yourself IceGrid in 10 minutes" article.

    Cheers,
    Benoit.