【问题标题】:jade error agent a1 died without being properly terminated. error state 2玉错误代理 a1 在没有被正确终止的情况下死亡。错误状态 2
【发布时间】:2018-05-25 10:36:48
【问题描述】:

我是翡翠的新手,我想设置一个拍卖代理来提供时间和物品数量,然后......但我收到了这个错误

  • jade 错误代理 a1 在没有被正确终止的情况下死亡。错误 状态 2 我的代码:

    int timeout=Integer.parseInt(JOptionPane.showInputDialog("What's Running time of Auction in sec?"));

          number=Integer.parseInt(JOptionPane.showInputDialog("What's the number of items?"));
    
          //service registration
          DFAgentDescription dfd = new DFAgentDescription();
          dfd.setName(getAID());
          ServiceDescription sd = new ServiceDescription();
          sd.setType("Uniform-Price-Auction");
          sd.setName("Uniform-Price-Auction");
          dfd.addServices(sd);
          try {
              DFService.register(this, dfd);
          }
          catch (FIPAException fe) {
              fe.printStackTrace();
          }
    
          // Add the behaviour serving queries from buyer agents
          addBehaviour(new getBids());
    
          // Add the behaviour serving purchase orders from buyer agents
          addBehaviour(new DetermineWinner(this,timeout*1000));
    
    
          gui=new ActioneerGUI();
          gui.setVisible(true);
          gui.setlabel1("We want to sell "+number+" items");
          gui.setlabel2("Auction is running...");
    

【问题讨论】:

  • 这段代码是行为代码吗?据我所知,在执行行为期间发生错误时会引发此错误。尝试将所有代码包装在 try-catch 块中以查找错误或查看 concole。有堆栈跟踪吗?

标签: java agents-jade


【解决方案1】:

考虑到 JADE 代理最终是一个 Java 线程,无论哪里发生错误,都会导致代理或线程被终止(如果我是正确的,这通常发生在 AgentWrapper 类中)。

还请记住,调用 JOptionPane(即 Swing)会影响两个线程:代理线程和可能导致并发问题的 Swing 线程。最好不要混淆它们;而是通过将最终用户应用程序/可视化与代理分开来使用代理的 O2A 接口。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-23
    • 2023-04-05
    • 2021-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多