Envoi de message entre 2 agents avec JADE
Résolu/Fermé
RJ1
Messages postés
20
Date d'inscription
lundi 8 mai 2017
Statut
Membre
Dernière intervention
16 mai 2017
-
8 mai 2017 à 13:57
RJ1 Messages postés 20 Date d'inscription lundi 8 mai 2017 Statut Membre Dernière intervention 16 mai 2017 - 8 mai 2017 à 23:11
RJ1 Messages postés 20 Date d'inscription lundi 8 mai 2017 Statut Membre Dernière intervention 16 mai 2017 - 8 mai 2017 à 23:11
A voir également:
- Envoi de message entre 2 agents avec JADE
- Recuperer message whatsapp - Guide
- Message d'absence thunderbird - Guide
- 2 comptes whatsapp - Guide
- Word numéro de page 1/2 - Guide
- Laisser un message vocal et raccrocher - Forum Mobile
2 réponses
KX
Messages postés
16734
Date d'inscription
samedi 31 mai 2008
Statut
Modérateur
Dernière intervention
24 avril 2024
3 015
8 mai 2017 à 15:18
8 mai 2017 à 15:18
Bonjour,
Merci de préciser où est la ligne 41...
java.lang.NullPointerExceptionQu'est ce que tu as comme code dans ta classe Véhicule ?
at rim.Véhicule$1.action(Véhicule.java:41)
Merci de préciser où est la ligne 41...
RJ1
Messages postés
20
Date d'inscription
lundi 8 mai 2017
Statut
Membre
Dernière intervention
16 mai 2017
Modifié le 8 mai 2017 à 22:50
Modifié le 8 mai 2017 à 22:50
package rim; import jade.core.ProfileImpl; import jade.core.Runtime; import jade.util.ExtendedProperties; import jade.util.leap.Properties; import jade.wrapper.AgentContainer; import jade.wrapper.AgentController; import jade.wrapper.ControllerException; public class MainContainer { public static void main(String[] args) { try { Runtime rt = Runtime.instance(); Properties p=new ExtendedProperties(); p.setProperty("gui", "true"); ProfileImpl pc=new ProfileImpl(p); AgentContainer container=rt.createMainContainer(pc); container.start(); AgentController agentController1= container.createNewAgent("coordinateur", "rim.Coordinateur", new Object[] {""}); agentController1.start(); AgentController agentController= container.createNewAgent("véhicule", "rim.Véhicule", new Object[] {""}); agentController.start(); } catch (ControllerException e) { e.printStackTrace(); } } }
package rim; import jade.core.AID; import jade.core.Agent; import jade.core.behaviours.CyclicBehaviour; import jade.lang.acl.ACLMessage; public class Coordinateur extends Agent{ @SuppressWarnings("serial") @Override protected void setup() { System.out.println("démarage de l'agent"); addBehaviour(new CyclicBehaviour() { @Override public void action() { ACLMessage message = new ACLMessage(ACLMessage.INFORM); message.addReceiver(new AID("Véhicule",AID.ISLOCALNAME)); message.setContent("alooooooo"); send(message); } } ); } }
package rim; import jade.core.Agent; import jade.core.behaviours.OneShotBehaviour; import jade.lang.acl.ACLMessage; @SuppressWarnings("serial") public class Véhicule extends Agent { protected void setup() { System.out.println("démarage de l'agent2222222"); addBehaviour(new OneShotBehaviour() { public void action() { ACLMessage message= receive(); if (message!= null){ System.out.println("Message received" + message.getContent()); } else { block(); } ACLMessage message1 = new ACLMessage(ACLMessage.INFORM); message1.addReceiver(message.getSender()); message1.setContent("la reponse"); send(message1); } }); } }
RJ1
Messages postés
20
Date d'inscription
lundi 8 mai 2017
Statut
Membre
Dernière intervention
16 mai 2017
8 mai 2017 à 22:43
8 mai 2017 à 22:43
l'erreur qui s'affiche
mai 08, 2017 9:39:47 PM jade.core.Runtime beginContainer
INFOS: ----------------------------------
This is JADE 4.4.0 - revision 6778 of 21-12-2015 12:24:43
downloaded in Open Source, under LGPL restrictions,
at http://jade.tilab.com/
----------------------------------------
mai 08, 2017 9:39:47 PM jade.imtp.leap.LEAPIMTPManager initialize
INFOS: Listening for intra-platform commands on address:
- jicp://192.168.1.5:1099
mai 08, 2017 9:39:47 PM jade.core.BaseService init
INFOS: Service jade.core.management.AgentManagement initialized
mai 08, 2017 9:39:47 PM jade.core.BaseService init
INFOS: Service jade.core.messaging.Messaging initialized
mai 08, 2017 9:39:47 PM jade.core.BaseService init
INFOS: Service jade.core.resource.ResourceManagement initialized
mai 08, 2017 9:39:47 PM jade.core.BaseService init
INFOS: Service jade.core.mobility.AgentMobility initialized
mai 08, 2017 9:39:47 PM jade.core.BaseService init
INFOS: Service jade.core.event.Notification initialized
mai 08, 2017 9:39:47 PM jade.mtp.http.HTTPServer <init>
INFOS: HTTP-MTP Using XML parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
mai 08, 2017 9:39:47 PM jade.core.messaging.MessagingService boot
INFOS: MTP addresses:
http://RIM-PC:7778/acc
mai 08, 2017 9:39:47 PM jade.core.AgentContainerImpl joinPlatform
INFOS: --------------------------------------
Agent container Main-Container@192.168.1.5 is ready.
--------------------------------------------
démarage de l'agent2222222
ERROR: Agent véhicule died without being properly terminated !!!
State was 2
démarage de l'agent
java.lang.NullPointerException
at rim.Véhicule$1.action(Véhicule.java:37)
at jade.core.behaviours.Behaviour.actionWrapper(Behaviour.java:344)
at jade.core.Agent$ActiveLifeCycle.execute(Agent.java:1552)
at jade.core.Agent.run(Agent.java:1491)
at java.lang.Thread.run(Unknown Source)
mai 08, 2017 9:39:47 PM jade.core.Runtime beginContainer
INFOS: ----------------------------------
This is JADE 4.4.0 - revision 6778 of 21-12-2015 12:24:43
downloaded in Open Source, under LGPL restrictions,
at http://jade.tilab.com/
----------------------------------------
mai 08, 2017 9:39:47 PM jade.imtp.leap.LEAPIMTPManager initialize
INFOS: Listening for intra-platform commands on address:
- jicp://192.168.1.5:1099
mai 08, 2017 9:39:47 PM jade.core.BaseService init
INFOS: Service jade.core.management.AgentManagement initialized
mai 08, 2017 9:39:47 PM jade.core.BaseService init
INFOS: Service jade.core.messaging.Messaging initialized
mai 08, 2017 9:39:47 PM jade.core.BaseService init
INFOS: Service jade.core.resource.ResourceManagement initialized
mai 08, 2017 9:39:47 PM jade.core.BaseService init
INFOS: Service jade.core.mobility.AgentMobility initialized
mai 08, 2017 9:39:47 PM jade.core.BaseService init
INFOS: Service jade.core.event.Notification initialized
mai 08, 2017 9:39:47 PM jade.mtp.http.HTTPServer <init>
INFOS: HTTP-MTP Using XML parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
mai 08, 2017 9:39:47 PM jade.core.messaging.MessagingService boot
INFOS: MTP addresses:
http://RIM-PC:7778/acc
mai 08, 2017 9:39:47 PM jade.core.AgentContainerImpl joinPlatform
INFOS: --------------------------------------
Agent container Main-Container@192.168.1.5 is ready.
--------------------------------------------
démarage de l'agent2222222
ERROR: Agent véhicule died without being properly terminated !!!
State was 2
démarage de l'agent
- Uncaught Exception for agent véhicule ***
java.lang.NullPointerException
at rim.Véhicule$1.action(Véhicule.java:37)
at jade.core.behaviours.Behaviour.actionWrapper(Behaviour.java:344)
at jade.core.Agent$ActiveLifeCycle.execute(Agent.java:1552)
at jade.core.Agent.run(Agent.java:1491)
at java.lang.Thread.run(Unknown Source)
KX
Messages postés
16734
Date d'inscription
samedi 31 mai 2008
Statut
Modérateur
Dernière intervention
24 avril 2024
3 015
8 mai 2017 à 23:02
8 mai 2017 à 23:02
Si la ligne 37 qui est dans ton message d'exception (qui était la ligne 41 avant) est bien celle qui apparaît ligne 37 dans le code ci-dessus alors le problème vient de
Tu as déjà un test
messagequi vaut null, ce qui fait planter
message.getSender()ligne 37.
Tu as déjà un test
if (message!= null){mais il ne s'applique pas sur ta ligne 37 donc il faudrait corriger ça pour gérer tous les cas. exemple :
protected void setup() { System.out.println("démarage de l'agent2222222"); addBehaviour(new OneShotBehaviour() { @Override public void action() { ACLMessage message = receive(); if (message != null) { System.out.println("Message received" + message.getContent()); ACLMessage message1 = new ACLMessage(ACLMessage.INFORM); message1.addReceiver(message.getSender()); message1.setContent("la reponse"); send(message1); } else { block(); } } }); }
RJ1
Messages postés
20
Date d'inscription
lundi 8 mai 2017
Statut
Membre
Dernière intervention
16 mai 2017
>
KX
Messages postés
16734
Date d'inscription
samedi 31 mai 2008
Statut
Modérateur
Dernière intervention
24 avril 2024
8 mai 2017 à 23:11
8 mai 2017 à 23:11
Merci
J'ai changé le code le msg de l'agent coordinateur vers l'agent véhicule ça marche bien mais non pour l'inverse c'est à dire le msg de l'agent véhicule vers l'agent coordinateur ne s'envoi pas
J'ai changé le code le msg de l'agent coordinateur vers l'agent véhicule ça marche bien mais non pour l'inverse c'est à dire le msg de l'agent véhicule vers l'agent coordinateur ne s'envoi pas