Agent acting as RMI serverImpl ?.. problems..


Subject: Agent acting as RMI serverImpl ?.. problems..
From: Ben Falchuk (bfalchuk@research.telcordia.com)
Date: Fri Aug 16 2002 - 20:06:03 MET DST


I am using Jade2.3 and implementing an Agent that implements a remote
RMI interface (for non-agents), and when it receives these invocations
it should proceed to send and receive ACL messages with other peer
agents (single platform, single container). As it messages with other
agents it is determining the 'response' to the calling RMI client.. When
its done messaging, it should return the response to the RMI client.

For example, the Agent:

public class ServerAgent extends Agent{
        public ServerAgent() throws RemoteException{
                super();
        }//constructor
        public void setup() {
                Behaviour b1 = new ServerAgentBehaviour1(this);addBehaviour(b1);
        }//setup
        ... etc.
}//ServerAgent

and its Behavior:

class ServerAgentBehaviour1 extends SimpleBehaviour
        implements ServerInterface{
        SDDPServerImplBehaviour1(SDDPServerImpl a){
                super(a);
                ...bind to RMI registry
        }//constructor

        public String remoteServerMethod(String req){
                if(req=="option a"){

                        ACLmsg = new ACLMessage(...);
                        ACLmsg.addRecipient(..some agent on platform..);
                        print("Agent: about to send ACL msg to peer");
                        parent.send(ACLmsg);
                        print("Agent: sent ACL msg");

                        blocking receive( ..for agent response..);
                        ..do stuff.. formulate response
                        parse incoming ACL Message
                        form response to RMI client
                        return response;
                }//if

        }//remote Method
..etc.
}//behaviour

Some remote Client program calls the Remote method as such:

try {
        obj = (ServerInterface)Naming.lookup("//"+host+"/thename..");
        print("client: calling remote interface");
        response = obj.remoteServerMethod(new String("option a"));
} catch (Exception e) {
        System.out.println("client: " + e.toString());
        e.printStackTrace();
}
printit("Response to sent messgae: "+response);
//------------------------------------------------------------------

The problem that i dont understand is that the client prints out the
message that its calling the remote interface, but always get a NULL
response. The ServerAgent gets to the point of issuing "send(msg)" to
some other agent and then the client program seems to get a NULL
response from the AgentServer agent!! Why does the flow of the program
go back to the client when the AgentServer is blocking and waiting for
the response to the ACL message?

%client: calling remote interface
%Agent: about to send ACL msg to peer
%SDDPclient: java.lang.NullPointerException
java.lang.NullPointerException
        at jade.core.Agent.notifySend(Agent.java:1628)
        at jade.core.Agent.send(Agent.java:1432)
        at rmi.AgentServerBehaviour1.IMlogin(... etc.

Any help appreciated,

--
Ben.
mailto:bfalchuk@research.telcordia.com



This archive was generated by hypermail 2a22 : Fri Aug 16 2002 - 20:03:52 MET DST