【问题标题】:JADE cannot find agentJADE 找不到代理
【发布时间】:2012-02-14 22:16:47
【问题描述】:

我是 JADE 新手,在加载代理时遇到了一些麻烦。

我创建了一个新的 IntelliJ 项目并在“依赖项”中添加了“jade.jar”和“commons-codec-1.3.jar”(我使用的是 JADE 4.1.1)并勾选了导出框(我也在没有勾选的情况下尝试)。然后,我将示例中的“HelloWorldAgent.java”添加到 src。我将运行配置设置为:

  • 主类:jade.Boot
  • 程序参数:-gui testAgent:HelloWorldAgent
  • 使用模块的类路径:jadeCW(我的项目名称)

当我使用此配置运行时,JADE 家伙确实启动了,但它没有找到“HelloWorldAgent”。输出是:

14-Feb-2012 21:43:08 jade.core.Runtime beginContainer
INFO: ----------------------------------
    This is JADE 4.1.1 - revision 6532 of 2011/11/18 16:21:34
    downloaded in Open Source, under LGPL restrictions,
    at http://jade.tilab.com/
----------------------------------------
Retrieving CommandDispatcher for platform null
14-Feb-2012 21:43:08 jade.imtp.leap.LEAPIMTPManager initialize
INFO: Listening for intra-platform commands on address:
- jicp://192.168.1.66:1099

14-Feb-2012 21:43:08 jade.core.BaseService init
INFO: Service jade.core.management.AgentManagement initialized
14-Feb-2012 21:43:08 jade.core.BaseService init
INFO: Service jade.core.messaging.Messaging initialized
14-Feb-2012 21:43:08 jade.core.BaseService init
INFO: Service jade.core.resource.ResourceManagement initialized
14-Feb-2012 21:43:08 jade.core.BaseService init
INFO: Service jade.core.mobility.AgentMobility initialized
14-Feb-2012 21:43:08 jade.core.BaseService init
INFO: Service jade.core.event.Notification initialized
14-Feb-2012 21:43:08 jade.mtp.http.HTTPServer <init>
INFO: HTTP-MTP Using XML parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
14-Feb-2012 21:43:08 jade.core.messaging.MessagingService boot
INFO: MTP addresses: http://unknown-00-19-c5-7e-cb-4b.home:7778/acc
14-Feb-2012 21:43:08 jade.core.AgentContainerImpl startBootstrapAgents
SEVERE: Cannot create agent testAgent: Class HelloWorldAgent for agent ( agent-identifier :name testAgent@192.168.1.66:1099/JADE ) not found [nested java.lang.ClassNotFoundException: HelloWorldAgent]
14-Feb-2012 21:43:08 jade.core.AgentContainerImpl joinPlatform
INFO: --------------------------------------
Agent container Main-Container@192.168.1.66 is ready.

关键问题显然是:

SEVERE: Cannot create agent testAgent: Class HelloWorldAgent for agent ( agent-identifier :name testAgent@192.168.1.66:1099/JADE ) not found [nested java.lang.ClassNotFoundException: HelloWorldAgent]

我尝试过使用 eclipse,但遇到了同样的问题,我也尝试过使用早期版本的 JADE,但还是没有运气。任何帮助将不胜感激。

非常感谢

【问题讨论】:

    标签: java agents-jade


    【解决方案1】:

    您需要在启动时传递类的完全限定名。在我的旧版 JADE 中,HelloWorldAgent 位于 examples.hello 包中。因此,您应该指定程序参数:-gui testAgent:examples.hello.HelloWorldAgent

    【讨论】:

    • +1:我还需要添加代理类的路径在类路径java -cp ~/JADE/lib/jade.jar:~/JADE/helloworldagent/: jade.Boot testAgent:HelloAgent中。
    【解决方案2】:

    只需在类名前添加包名

    -gui testAgent:packageName.HelloWorldAgent

    【讨论】:

      【解决方案3】:

      你需要添加:

      -gui nameAgent:packageName.className
      

      【讨论】:

        【解决方案4】:

        似乎我放置“jade.jar”和“commons-codec-1.3.jar”的位置是问题所在(我最初将它们放在 /Library/Java/Extensions(在 OSX lion 中)中)。我尝试删除它们,将它们放在其他地方并再次尝试,现在它可以工作了。不完全确定为什么介意!

        【讨论】:

          【解决方案5】:

          在我的情况下,它是代理名称后面的一个额外空格:

          -gui nameAgent: packageName.className
          

          删除空间并将项目添加到类路径后,一切正常。

          -gui nameAgent:packageName.className
          

          【讨论】:

            【解决方案6】:

            我遇到了另一个问题,所以我想我会在这里为它编写解决方案,以便它可以帮助某人。 使用“-cp”或“-classpath”编写类路径时,仅将路径写入输出文件夹名称,不包括为命名空间创建的文件夹。例如,如果您的代理类在命名空间“sample.namespace”中,javac 命令将创建一个目录结构,如“bin\sample\namespace”并将文件放在那里。在这种情况下,不要在类路径中包含“sample\namespace”。只是“bin”文件夹的路径,输出文件夹(bin)的名称可以不同。

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2014-09-25
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多