Не пытаясь найти проблемы с вашим кодом, я предлагаю использовать приведенный ниже код для решения вашей ошибки.
Код инициализации для агента и добавления в контейнер
package package.se.samplejade;
import jade.wrapper.AgentController;
import jade.wrapper.StaleProxyException;
public class LaunchAgents {
private static final String AGENT_CLASS_STRING ="package.se.samplejade.SampleAgent";
private static final String AGENTNAME_STRING = "sampleAgent";
public static void main(String[] args) {
LaunchAgents LaunchAgents = new LaunchAgents();
LaunchAgents.initilizeAgent();
}
/**
* Creates a new agent and adds it to the container
*
* @param
* @return true or false
*/
public boolean initilizeAgent() {
AgentController agentcontroller = null;
Object[] initObjects = new Object[2];
initObjects[0] = new Object(); // add any object needed to initialize the agent
initObjects[1] = new Object();
try {
agentcontroller = Container.getController().createNewAgent(AGENTNAME_STRING, AGENT_CLASS_STRING,
initObjects);
agentcontroller.start();
return true;
} catch (StaleProxyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
}
}
Инициализация контейнера JADE
package.se.samplejade ;
import jade.core.Profile;
import jade.core.ProfileImpl;
import jade.wrapper.ContainerController;
public final class Container {
// get a JADE runtime
private static jade.core.Runtime runtime = jade.core.Runtime.instance();
// Create a profile, where the launch arguments are stored
private static Profile profile2 = new ProfileImpl();
private static Profile profile = new ProfileImpl();
// create the Main-container
private static ContainerController mainContainer = null;
private static ContainerController containerController = null;
/**
* Returns the path of the container to the JADE agents
*/
public synchronized static ContainerController getController() {
// create the Main-container
if (mainContainer == null) {
profile.setParameter(Profile.CONTAINER_NAME, "Container");
profile.setParameter(Profile.GUI, "true");
mainContainer = runtime.createMainContainer(profile2);
containerController = runtime.createAgentContainer(profile);
}
return containerController;
}
}
Код агента
package.se.samplejade;
import jade.core.Agent;
public class SampleAgent extends Agent {
@Override
protected void setup() {
//Put your agent initialization code with the objects passed in the initialization
}
}