Archived

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

Getting Couldn't invoke on the object to get its interface while binding to IcePack

Folks,
I am tring to bind a object to IcePack, seems like I have wrong Sequence or something.
Here is what I am doing:

Ice.Object object = new ThroughputI();
Identity id = Ice.Util.stringToIdentity("MyThroughput") ;
Ice.ObjectPrx objPtr = adapter.add(object, id);
adapter.activate();

IcePack.AdminPrx admin = IcePack.AdminPrxHelper.checkedCast(communicator.stringToProxy("IcePack/Admin"));

admin.addObject(objPtr);


Thanks

Comments

  • mes
    mes California
    Hi,

    I don't see anything wrong with your code, so please provide more details about your problem. Are you getting an exception? If so, it would be helpful to see it. Is this code failing? Or is another application unable to locate the object you've registered?

    Please also describe your environment: Ice version, operating system, compiler, etc.

    Take care,
    - Mark
  • I am on windows 2000, Ice 2.1.2. JDK 1.4.2. This is the first app I am writing, meaning it was never working :) for me.

    The Exception I get is

    ERROR Server 15:14:24.265 - AJAGLAN2-2K|test IcePack.DeploymentException
    reason = "Couldn't invoke on the object to get its interface."
    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:2011)
    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 Server.run(Server.java:24)
    at Server.main(Server.java:41)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)


    I tried Tie approach also.

    My code is: Server.java

    Ice.ObjectAdapter adapter = communicator.createObjectAdapter("Throughput");
    Ice.Object object = new _ThroughputTie( new ThroughputI());
    ObjectPrx objPtr = adapter.add(object, Ice.Util.stringToIdentity(SecurityId.class.getName()));
    adapter.activate();
    IcePack.AdminPrx admin = IcePack.AdminPrxHelper.checkedCast(communicator.stringToProxy("IcePack/Admin"));
    admin.addObject(objPtr);
    communicator.waitForShutdown();




    public final class ThroughputI implements _ThroughputOperations {
    ...
    }

    Thanks,
    Anil
  • benoit
    benoit Rennes, France
    It looks like IcePack failed to get the type of your object. Unfortunately it doesn't say why :( (we will fix this). It could be because your object adapter endpoints are not accessible to the IcePack registry process (IcePack needs to establish a connection to your server in order to get the type of the object). If you're willing to re-compile IcePack to figure this out, you could print the exception that IcePack catches in Ice-2.1.2/src/IcePack/AdminI.cpp line 1402.

    Otherwise, to avoid IcePack to remotely call on your object to get its type, you could use the IcePack::Admin::addObjectWithType() method, for example:
    Ice.Object object = new ThroughputI();
    ...
    admin.addObjectWithType(objPtr, object->ice_id());
    

    Benoit.
  • mes
    mes California
    Hi,

    When you register an object with IcePack using addObject, the IcePack registry tries to determine the object's type by calling ice_id on it. The exception indicates that this attempt failed. This could happen when the server is not running at the time the object is registered. It could also happen if the server's object adapter does not have its endpoints configured properly when the IcePack service is running on a different host.

    I suggest running your server as well as the IcePack registry with the property Ice.Trace.Network=2. If you're still having trouble, please post the trace messages.

    Take care,
    - Mark
  • Thanks for the quick reply.

    I did:
    Identity id = new Identity() ;
    id.name = SecurityId.class.getName() ;
    ObjectPrx objPtr = adapter.add(object, id);
    adapter.activate();
    IcePack.AdminPrx admin = IcePack.AdminPrxHelper.checkedCast(communicator.stringToProxy("IcePack/Admin"));
    admin.addObjectWithType(objPtr, object.ice_id());
    System.out.println("Id: " + object.ice_id());

    For some reason the "Id: " is printing ::Demo::Throughput. I was expecting "SecurityId". as this was name I intended.

    Anyways the client is notable to resolve this name.
    IcePack.QueryPrx query = IcePack.QueryPrxHelper.checkedCast(communicator.stringToProxy("IcePack/Query"));
    Identity id = Ice.Util.stringToIdentity("::Demo::Throughput") ;

    Ice.ObjectPrx base= query.findObjectById(id) ;

    I get:
    IcePack.QueryPrx query = IcePack.QueryPrxHelper.checkedCast(communicator.stringToProxy("IcePack/Query"));
    //Identity id = Ice.Util.stringToIdentity(SecurityId.class.getName()) ;
    Identity id = Ice.Util.stringToIdentity("::Demo::Throughput") ;

    Ice.ObjectPrx base= query.findObjectById(id) ;


    Thanks again,
  • mes
    mes California
    Hi,

    There are two "ids" and it can be easy to get them confused. The first is the object identity, which you are defining as SecurityId.class.getName(). The second is the object's type id, which is the value returned by ice_id and represents the most-derived Slice interface or class implemented by the object. The IcePack operation findObjectById really should be named findObjectByIdentity, as that is how it actually works. The findObjectByType operation uses the type id, which in this case is "::Demo::Throughput".

    So, doing the following should work (assuming that you've got your endpoints and IcePack configured correctly):

    Identity id = Ice.Util.stringToIdentity(SecurityId.class.getName ()) ;
    Ice.ObjectPrx base= query.findObjectById(id) ;
    Demo.ThroughputPrx t = Demo.ThroughputPrxHelper.checkedCast(base);

    Take care,
    - Mark
  • Thanks Mes. Awesome !!

    I can get it working by adding
    Throughput.Throughput=throughput:default
    Throughput.Endpoints=default

    A minor thing though, shouldn't we default them.