javaagents-jade

Why does to register agents return this error: FIPAAgentManagement.MissingParameter?


I want to register several agents.

For doing this I'm using the following code

The clases

public class Main {

public static void main(String[] args) {
    String[] services = {"-gui"};
    Boot.main(services);
    Agent1 = new Agent1(0,0,"a");
}

}

public class Agent1 extends Agent{

public Agent1(int x, int y, String name) {
        super(x, y, name);
        setup();
    }

protected void setup(){
        System.out.println("hi");
        ServiceDescription sd  = new ServiceDescription();
        sd.setType( "buyer" );
        sd.setName( "asa" );
        register( sd );
    }  

void register( ServiceDescription sd){
            DFAgentDescription dfd = new DFAgentDescription();
            dfd.setName(getAID());
            dfd.addServices(sd);

try {  
    DFService.register(this, dfd );  
}
catch (FIPAException fe) { fe.printStackTrace(); }

}

protected void takeDown(){
        System.out.println("bye");
    }

}

But I am getting the following error:

jade.domain.FIPAAgentManagement.MissingParameter: (missing-parameter df-agent-description name)

How can I fix the error?

Thanks


Solution

  • You're not creating the agent correctly. The getAID() will return null, and the DFAgentDescription becomes invalid.

    You should pass -agents to jade.Boot, and it will create the agent for you.

    public static void main(String[] args) {
        // the agent's name is agent1, change xy.zy to your package
        String[] services = {"-gui", "-agents", "agent1:xy.zy.Agent1"};
        Boot.main(services);
    }
    

    You don't need Agent1 = new Agent1(0,0,"a"); and you don't need the constructor in Agent1. The method setup() is called automatically.