我创建了两个代理,它运行良好。但是当我添加本体类并注册本体时,我无法创建代理...我遇到了以下错误。

Jun 1, 2012 8:56:55 AM jade.core.BaseService init
INFO: Service jade.core.management.AgentManagement initialized
Jun 1, 2012 8:56:55 AM jade.core.BaseService init
INFO: Service jade.core.messaging.Messaging initialized
Jun 1, 2012 8:56:55 AM jade.core.BaseService init
INFO: Service jade.core.mobility.AgentMobility initialized
Jun 1, 2012 8:56:55 AM jade.core.BaseService init
INFO: Service jade.core.event.Notification initialized
Jun 1, 2012 8:56:55 AM jade.core.messaging.MessagingService clearCachedSlice
INFO: Clearing cache
Jun 1, 2012 8:56:55 AM jade.mtp.http.HTTPServer <init>
INFO: HTTP-MTP Using XML parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
Jun 1, 2012 8:56:55 AM jade.core.messaging.MessagingService boot
INFO: MTP addresses:
http://169.254.108.164:7778/acc
Jun 1, 2012 8:56:55 AM jade.core.AgentContainerImpl startBootstrapAgents
SEVERE: Cannot create agent STMAgent: An undeclared exception was thrown [nested   java.lang.ExceptionInInitializerError]
Jun 1, 2012 8:56:55 AM jade.core.AgentContainerImpl startBootstrapAgents
SEVERE: Cannot create agent REquestAgent: An undeclared exception was thrown [nested java.lang.NoClassDefFoundError: Could not initialize class FruitOntology.FruitOntology]
Jun 1, 2012 8:56:55 AM jade.core.AgentContainerImpl joinPlatform


类路径正确。本体类的路径也是正确的。这是什么原因?请帮我............
我发现错误..这是在我的本体类上..
谢谢..

最佳答案

关键错误消息似乎是:

SEVERE: Cannot create agent REquestAgent: An undeclared exception was thrown
  [nested java.lang.NoClassDefFoundError:
   Could not initialize class FruitOntology.FruitOntology]


您的代码没有在包FruitOntology中找到类FruitOntology(这不是一个很好的包名-通常,包名以小写字母开头,并且通常遵循反转域的约定组织名称)。

由于您没有显示任何代码,因此我们只能猜测为什么会出现此错误。您是否可能在某个地方的配置文件中拼错了名称?在您的项目中执行grep,以查看FruitOntology.FruitOntology的位置。它可能不在普通的Java代码中,因为您会因缺少类而遇到编译错误,除非出于某种原因使用Java Reflection。

09-11 18:32