Archived

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

Unable to register object in icepack registry

Hello,

I am trying to automatically register some objects in the registry after the adapter being created with the following code (object names are given in the command line):
public class EchoAgent extends Application {
	public int run(String[] args) {
		AdminPrx admin = AdminPrxHelper.checkedCast(communicator().stringToProxy(
			"IcePack/Admin"));
		ObjectAdapter adapter = communicator().createObjectAdapter("LocalNode");
		adapter.activate();
		for (int i = 0; i < args.length; i++) {
			Identity id = new Identity();
			//id.category = "Agents";
			id.name = args[i];
			ObjectPrx agent = adapter.add(new EchoAgentServant(args[i]), id);
			try {
				admin.removeObject(agent);
			} catch (ObjectNotExistException e1) {
				// e1.printStackTrace();
			}
			try {
				admin.addObject(agent);
				System.out.println(Util.identityToString(agent.ice_getIdentity())
					+ " registered");
			} catch (ObjectExistsException e) {
				System.out.println(Util.identityToString(agent.ice_getIdentity())
					+ " already registered");
				//e.printStackTrace();
			} catch (DeploymentException e) {
				e.printStackTrace();
				communicator().shutdown();
				return 1;
			}
		}
		communicator().waitForShutdown();
		return 0;
	}

	public static void main(String[] args) {
		EchoAgent app = new EchoAgent();
		System.exit(app.main("EchoAgent", args));
	}
}

The adapter is correctly registered, but the admin.addObject() call always fails with a DeployementException:
IcePack.DeploymentException
    reason = "Couldn't invoke on the object to get its interface."
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
	at java.lang.Class.newInstance0(Class.java:350)
	at java.lang.Class.newInstance(Class.java:303)
	at IceInternal.BasicStream$DynamicUserExceptionFactory.createAndThrow(BasicStream.java:1780)
	at IceInternal.BasicStream.throwException(BasicStream.java:1413)
	at IcePack._AdminDelM.addObject(_AdminDelM.java:91)
	at IcePack.AdminPrxHelper.addObject(AdminPrxHelper.java:70)
	at IcePack.AdminPrxHelper.addObject(AdminPrxHelper.java:54)
	at EchoAgent.run(EchoAgent.java:40)
	at Ice.Application.main(Application.java:66)
	at Ice.Application.main(Application.java:31)
	at EchoAgent.main(EchoAgent.java:59)


(icepack config file attached)

Not sure of this, but this code used to work with Ice 1.5.1 (still investigating).

Comments

  • mes
    mes California
    Hi,

    In response to a call to addObject, the IcePack registry attempts to call ice_id on the given proxy. If an exception occurs, the registry returns DeploymentException.

    I suggest setting Ice.Trace.Network=3 in the IcePack registry to determine the addressing information the registry is using in its attempt to contact the object. If the object and the registry are on different hosts, perhaps the object's endpoints are not configured correctly.

    Take care,
    - Mark
  • Problem solved but strong warning!

    It appears that in the config file we used 'LocalNode' as the adapter id.
    This is a very bad idea!
    This name apparently collapses with some internal id, for example if you issue 'adapter endpoints LocalNode' you get the error:
    error: IcePack::NodeUnreachableException
    
    which means that the id was identified as something else (you certainly know why).

    More, the config file has been mistakenly modified so that the 'LocalNode.Endpoints' property was actually 'LocalNode.Endpoint'.

    It also appears that not defining a xxx.Endpoints leads to a DeploymentException.

    I don't know if a missing endpoints property can be equivalent to 'default', but if this is not the case, then an error/warning must be issued if such a property is missing.

    To conclude:

    You got a DeploymentException if:
    - You set 'LocalNode' to an adapter id
    - You don't set its Endpoints property.

    Hope this help.
    --
    Christophe