RE: [jade-develop] Create agent question


Subject: RE: [jade-develop] Create agent question
From: Caire Giovanni (Giovanni.Caire@TILAB.COM)
Date: Mon Aug 12 2002 - 14:09:23 MET DST


Hi,

The getContainerController() method works correctly only when the agent is actually "living" on a container (e.g. in the setup() method or in a behaviour). Before that time (e.g. in the agent constructor) the agent "does not know" its container and therefore the getContainerController() method fails (the exception thrown is not really meaningful; it will be improved).

To solve your problem just move the code in the agent setup().

As a general guideline, note that developers should add all initializations in the setup() method and not in the constructor.

Bye

Giovanni

-----Original Message-----
From: Juan C. Martinez [mailto:jumartin@etse.urv.es]
Sent: mercoledì 7 agosto 2002 11.15
To: JADE
Subject: [jade-develop] Create agent question

Hello jader's

   I am updating my application from jade 2.4 to jade 2.6. I have an
agent that create others agents, and I am using the following code:

public class AgentCreator extends Agent{

....

   String Name = Txt_Name.getText()

 /* try{ Agentwrk Ag = new Agentwrk(); **** CODE IN JADE 2.4 *****
          Ag.doStart(Name);
       }
      catch (Exception err) {System.out.println("ERROR AL CREAR EL
AGENTE: " + err);} */

   try {PlatformController container = getContainerController(); //
***** CODE JADE 2.6 *****
        AgentController Ag = container.createNewAgent(Name, "Agentwrk",
null);
        Ag.start();
       }
   catch (jade.wrapper.ControllerException err)
{System.out.println("ERROR AL CREAR EL AGENTE: " + err);}

.....

   The commented code is in jade 2.4.

   When I use the code for jade 2.6 the following Exception occurs:

         java.lang.ClassCastException: jade.core.DummyToolkit

   Does any body knows what the problem is????

   Thanks in advance.

--
____________________________________________________

Juan C. Martínez Miranda Departament d'Enginyeria Informàtica i Matemàtiques Escola Tècnica Superior d'Enginyeria Universitat Rovira i Virgili Campus Sescelades Avinguda dels Paìsos Catalans, 26 43007 Tarragona Tel. 977 55 85 16 Fax. 977 55 97 10 E-mail: jumartin@etse.urv.es

_______________________________________________ jade-develop mailing list jade-develop@sharon.cselt.it http://sharon.cselt.it/mailman/listinfo/jade-develop UNSUBSCRIBE INSTRUCTIONS AT http://jade.cselt.it/mailing.htm#unsubscribe



This archive was generated by hypermail 2a22 : Mon Aug 12 2002 - 14:09:30 MET DST