Home Help Center

Java client can't work with a proxy returned by a java server

PeteHPeteH Member Peter HugOrganization: Warehouse Optimization LLCProject: APAL
Here is an interface implemented in a java server (port 10010) that i'm using in a java client port 10000):
// client stuff ------------------------------------------
interface SapResponse {
		bool isAlive();
};



// server stuff ------------------------------------------
interface SapRequest {
		bool isAlive();
};

interface SapRequestManager{
		SapRequest* registerSapResponse(int iClientID, SapResponse* prxResponse);
};

Here is how the Server implements SapRequestManager.registerSapResponse:
public class SapRequestManagerI extends _SapRequestManagerDisp
{
...

  public SapRequestPrx
  registerSapResponse(int iClientID,
                      SapResponsePrx prxSapResponse,
                      Ice.Current current) throws SapCxnError
  {
    try
    {
      prxSapResponse.isAlive();
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
      
    Ice.Identity     iceIDSapRequest = new Ice.Identity();

    iceIDSapRequest.category = "SapRequest";
    iceIDSapRequest.name = "" + iClientID;

    return   prxSapRequest = SapRequestPrxHelper.uncheckedCast(current.adapter.createProxy(iceIDSapRequest));
  }
  
...
}

Here is how the client invokes SapRequestManager.registerSapResponse:
try
{
	SapResponsePrx        prxSapResponse = SapResponsePrxHelper.checkedCast(Server.communicator().stringToProxy("SapResponse:default -p 10000"));
	SapRequestManagerPrx  prxSapRequestManager = SapRequestManagerPrxHelper.checkedCast(Server.communicator().stringToProxy("SapRequestManager:default -p 10010"));
	SapRequestPrx         prxSapRequest;

	// register the a SapResponse proxy with the remote SapRequestManager and register the returned SapRequest proxy with the RequestSubmitter
	prxSapRequest = prxSapRequestManager.registerSapResponse(Server.M_iPort, prxSapResponse);

	// Check if the return object works
	prxSapRequest.isAlive();
}
catch(Exception e)
{
	e.printStackTrace();
}

The problem is that the prxSapRequest the client receives from the server craps out with this exception:
Ice.ObjectNotExistException
    id.name = "10000"
    id.category = "SapRequest"
    facet = ""
    operation = "isAlive"
        at IceInternal.Outgoing.invoke(Outgoing.java:147)
        at ISapCxn._SapRequestDelM.isAlive(_SapRequestDelM.java:79)
        at ISapCxn.SapRequestPrxHelper.isAlive(SapRequestPrxHelper.java:94)
        at ISapCxn.SapRequestPrxHelper.isAlive(SapRequestPrxHelper.java:66)
        at RequestSubmitter.getSapRequestPrx(RequestSubmitter.java:46)
        at RequestSubmitter.run(RequestSubmitter.java:220)
  SapRequest.executeFunction failed: null

The server can call isAlive() on the proxy passed without any problem. operational.

Sorry I'm not a java coder so maybe that is where the problem. Conceptually I do the same in C++ and the C++ server works fine with the client.

Any ideas where I'm screwing up?

Comments

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
            return   prxSapRequest = SapRequestPrxHelper.uncheckedCast(current.adapter.createProxy(iceIDSapRequest));
    

    Seems you never add the Object to the adapter, you just return a proxy to a non existing servant Ice.ObjectNotExistException is expected in this case.
  • PeteHPeteH Member Peter HugOrganization: Warehouse Optimization LLCProject: APAL
    Thanks Jose, but no, that isn't the problem.

    If the client creates the proxy manually like this, all works ok:
    SapRequestPrx prxSapRequest = SapRequestPrxHelper.checkedCast(Server.communicator().stringToProxy("SapRequest:default -p 10010"));
    prxSapRequest.isAlive()
    

    If the server forgot to add the SapRequest object to its adapter, than this would not work. So there is something wrong with the proxy I return from the server, but what?
  • matthewmatthew NL, CanadaMember Matthew NewhookOrganization: ZeroC, Inc.Project: Internet Communications Engine ✭✭✭
    This proxy:

    SapRequest:default -p 10010

    Has the identity id.name="SapRequest", id.category="".

    The proxy reporting the object not exist exception is:

    id.name = "10000" id.category = "SapRequest"

    As you can see they are not the same.

    The identity id.name = "10000" id.category = "SapRequest"
    in stringified form is: "SapRequest/1000".

    This format of a stringified proxy is documented https://doc.zeroc.com/display/Ice/Proxy+and+Endpoint+Syntax
  • PeteHPeteH Member Peter HugOrganization: Warehouse Optimization LLCProject: APAL
    Hmm, yes I have these two:
    SapRequest:default -p 10010
    SapRequest/10000:default -p 10010
    

    But I only have one class:
    public class SapRequestI extends _SapRequestDisp {/* */}
    

    and I register that class like this:
    adapter.add(new SapRequestI(), communicator().stringToIdentity("SapRequest"));
    adapter.activate();
    

    I thought that the Ice.current.id.category was relevant to invoke the correct interface and I could then examine the Ice.current.id.name to connect to the apropriate object.

    So do I need to implement a locator to make this work?
  • PeteHPeteH Member Peter HugOrganization: Warehouse Optimization LLCProject: APAL
    PeteH wrote: »
    So do I need to implement a locator to make this work?

    Indeed I do :). I simply missed a whole lot of magic a C++ macro injected into the code. Once I added a locator all worked just fine.

    Thanks for the help.
Sign In or Register to comment.